Merge branch 'master' into feature-magic

This commit is contained in:
n1474335 2018-01-22 20:04:51 +00:00
commit 57314b77e5
8 changed files with 46 additions and 21 deletions

View file

@ -903,9 +903,9 @@ const Utils = {
* "Pretty" CyberChef recipe formats are designed to be included in the fragment (#) or query (?)
* parts of the URL. They can also be loaded into CyberChef through the 'Load' interface. In order
* to make this format as readable as possible, various special characters are used unescaped. This
* reduces the amount of percent-encoding included in the URL which is typically difficult to read,
* as well as substantially increasing the overall length. These characteristics can be quite
* offputting for users.
* reduces the amount of percent-encoding included in the URL which is typically difficult to read
* and substantially increases the overall length. These characteristics can be quite off-putting
* for users.
*
* @param {Object[]} recipeConfig
* @param {boolean} newline - whether to add a newline after each operation
@ -922,12 +922,11 @@ const Utils = {
name = op.op.replace(/ /g, "_");
args = JSON.stringify(op.args)
.slice(1, -1) // Remove [ and ] as they are implied
// We now need to switch double-quoted (") strings to single-quotes (') as these do not
// need to be percent-encoded.
// We now need to switch double-quoted (") strings to single quotes (') as single quotes
// do not need to be percent-encoded.
.replace(/'/g, "\\'") // Escape single quotes
.replace(/\\"/g, '"') // Unescape double quotes
.replace(/(^|,|{|:)"/g, "$1'") // Replace opening " with '
.replace(/"(,|:|}|$)/g, "'$1"); // Replace closing " with '
.replace(/"((?:[^"\\]|\\.)*)"/g, "'$1'") // Replace opening and closing " with '
.replace(/\\"/g, '"'); // Unescape double quotes
disabled = op.disabled ? "/disabled": "";
bp = op.breakpoint ? "/breakpoint" : "";

View file

@ -2411,13 +2411,13 @@ const OperationConfig = {
args: [
{
name: "Split delimiter",
type: "binaryShortString",
value: StrUtils.SPLIT_DELIM
type: "editableOption",
value: StrUtils.SPLIT_DELIM_OPTIONS
},
{
name: "Join delimiter",
type: "option",
value: StrUtils.DELIMITER_OPTIONS
type: "editableOption",
value: StrUtils.JOIN_DELIM_OPTIONS
}
]
},
@ -2440,7 +2440,7 @@ const OperationConfig = {
{
name: "Invert condition",
type: "boolean",
value: SeqUtils.SORT_REVERSE
value: false
},
]
},

View file

@ -65,12 +65,28 @@ const StrUtils = {
* @constant
* @default
*/
SPLIT_DELIM: ",",
SPLIT_DELIM_OPTIONS: [
{name: "Comma", value: ","},
{name: "Space", value: " "},
{name: "Line feed", value: "\\n"},
{name: "CRLF", value: "\\r\\n"},
{name: "Semi-colon", value: ";"},
{name: "Colon", value: ":"},
{name: "Nothing (separate chars)", value: ""}
],
/**
* @constant
* @default
*/
DELIMITER_OPTIONS: ["Line feed", "CRLF", "Space", "Comma", "Semi-colon", "Colon", "Nothing (separate chars)"],
JOIN_DELIM_OPTIONS: [
{name: "Line feed", value: "\\n"},
{name: "CRLF", value: "\\r\\n"},
{name: "Space", value: " "},
{name: "Comma", value: ","},
{name: "Semi-colon", value: ";"},
{name: "Colon", value: ":"},
{name: "Nothing (join chars)", value: ""}
],
/**
* Split operation.
@ -80,14 +96,20 @@ const StrUtils = {
* @returns {string}
*/
runSplit: function(input, args) {
let splitDelim = args[0] || StrUtils.SPLIT_DELIM,
joinDelim = Utils.charRep[args[1]],
let splitDelim = args[0],
joinDelim = args[1],
sections = input.split(splitDelim);
return sections.join(joinDelim);
},
/**
* @constant
* @default
*/
DELIMITER_OPTIONS: ["Line feed", "CRLF", "Space", "Comma", "Semi-colon", "Colon", "Nothing (separate chars)"],
/**
* Filter operation.
*