2
0
mirror of https://github.com/gchq/CyberChef synced 2025-12-05 23:53:27 +00:00

Compare commits

...

6 Commits

Author SHA1 Message Date
n1474335
ec205f4f7d 7.5.3 2018-01-18 19:53:01 +00:00
n1474335
512487328d Fixed bugs in pretty recipe format generation 2018-01-18 18:35:17 +00:00
n1474335
6fbb2f26d1 7.5.2 2018-01-18 15:27:26 +00:00
n1474335
c91bfeaa81 Merge branch 'qistoph-SplitAndJoin' 2018-01-18 15:26:34 +00:00
n1474335
aa2b3b2843 Changed order of split delimiters, placing comma first. 2018-01-18 15:26:09 +00:00
Chris van Marle
90d8be48d4 Make Split more flexible so it can be used to join 2018-01-17 15:52:25 +01:00
6 changed files with 35 additions and 18 deletions

2
package-lock.json generated
View File

@@ -1,6 +1,6 @@
{
"name": "cyberchef",
"version": "7.5.1",
"version": "7.5.3",
"lockfileVersion": 1,
"requires": true,
"dependencies": {

View File

@@ -1,6 +1,6 @@
{
"name": "cyberchef",
"version": "7.5.1",
"version": "7.5.3",
"description": "The Cyber Swiss Army Knife for encryption, encoding, compression and data analysis.",
"author": "n1474335 <n1474335@gmail.com>",
"homepage": "https://gchq.github.io/CyberChef",

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

@@ -2125,13 +2125,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
}
]
},

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,8 +96,8 @@ 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);

View File

@@ -443,6 +443,7 @@ App.prototype.getRecipeConfig = function() {
/**
* Given a recipe configuration, sets the recipe to that configuration.
*
* @fires Manager#statechange
* @param {Object[]} recipeConfig - The recipe configuration
*/
App.prototype.setRecipeConfig = function(recipeConfig) {
@@ -487,6 +488,7 @@ App.prototype.setRecipeConfig = function(recipeConfig) {
// Unpause auto bake
this.autoBakePause = false;
window.disptchEent(this.manager.statechange);
};