diff --git a/src/core/config/Categories.js b/src/core/config/Categories.js index dd858ea4..270c1e1e 100755 --- a/src/core/config/Categories.js +++ b/src/core/config/Categories.js @@ -187,8 +187,8 @@ const Categories = [ "Parse UNIX file permissions", "Swap endianness", "Parse colour code", - "Escape String", - "Unescape String", + "Escape string", + "Unescape string", ] }, { diff --git a/src/core/config/OperationConfig.js b/src/core/config/OperationConfig.js index d6a12845..40571293 100755 --- a/src/core/config/OperationConfig.js +++ b/src/core/config/OperationConfig.js @@ -3263,15 +3263,15 @@ const OperationConfig = { } ] }, - "Escape String": { - description: "Escapes a string so that it can be embedded in another. For example, Don't stop me now becomes Don\\'t stop me now.", + "Escape string": { + description: "Escapes special characters in a string so that they do not cause conflicts. For example, Don't stop me now becomes Don\\'t stop me now.", run: StrUtils.runEscape, inputType: "string", outputType: "string", args: [] }, - "Unescape String": { - description: "Unescapes a string that was embedded inside another so that it can be used in it's own right. For example, Don\\'t stop me now becomes Don't stop me now.", + "Unescape string": { + description: "Unescapes characters in a string that have been escaped. For example, Don\\'t stop me now becomes Don't stop me now.", run: StrUtils.runUnescape, inputType: "string", outputType: "string", diff --git a/src/core/operations/StrUtils.js b/src/core/operations/StrUtils.js index 5d0c0a43..21b19e8a 100755 --- a/src/core/operations/StrUtils.js +++ b/src/core/operations/StrUtils.js @@ -448,6 +448,7 @@ const StrUtils = { return outputs.join(sampleDelim); }, + /** * @constant * @default @@ -464,7 +465,7 @@ const StrUtils = { ], /** - * Escapes a string for embedding in another string. + * Escape string operation. * * @author Vel0x [dalemy@microsoft.com] * @@ -483,8 +484,9 @@ const StrUtils = { return StrUtils._replaceByKeys(input, "unescaped", "escaped"); }, + /** - * Unescapes a string that was part of another string + * Unescape string operation. * * @author Vel0x [dalemy@microsoft.com] * @@ -503,9 +505,10 @@ const StrUtils = { return StrUtils._replaceByKeys(input, "escaped", "unescaped"); }, + /** * Replaces all matching tokens in ESCAPE_REPLACEMENTS with the correction. The - * ordering is determined by the pattern_key and the replacement_key. + * ordering is determined by the patternKey and the replacementKey. * * @author Vel0x [dalemy@microsoft.com] * @author Matt C [matt@artemisbot.uk] @@ -517,7 +520,10 @@ const StrUtils = { */ _replaceByKeys: function(input, patternKey, replacementKey) { let output = input; - if (patternKey === "escaped") output = Utils.parseEscapedChars(input); // I've wrapped this to catch the \\x encoded characters + + // Catch the \\x encoded characters + if (patternKey === "escaped") output = Utils.parseEscapedChars(input); + StrUtils.ESCAPE_REPLACEMENTS.forEach(replacement => { output = output.split(replacement[patternKey]).join(replacement[replacementKey]); });