Merge branch 'master' of https://github.com/gariev/CyberChef
This commit is contained in:
commit
a73decc792
@ -206,7 +206,7 @@ class Utils {
|
|||||||
* Utils.parseEscapedChars("\\n");
|
* Utils.parseEscapedChars("\\n");
|
||||||
*/
|
*/
|
||||||
static parseEscapedChars(str) {
|
static parseEscapedChars(str) {
|
||||||
return str.replace(/\\([bfnrtv'"]|[0-3][0-7]{2}|[0-7]{1,2}|x[\da-fA-F]{2}|u[\da-fA-F]{4}|u\{[\da-fA-F]{1,6}\}|\\)/g, function(m, a) {
|
return str.replace(/\\([abfnrtv'"]|[0-3][0-7]{2}|[0-7]{1,2}|x[\da-fA-F]{2}|u[\da-fA-F]{4}|u\{[\da-fA-F]{1,6}\}|\\)/g, function(m, a) {
|
||||||
switch (a[0]) {
|
switch (a[0]) {
|
||||||
case "\\":
|
case "\\":
|
||||||
return "\\";
|
return "\\";
|
||||||
@ -219,6 +219,8 @@ class Utils {
|
|||||||
case "6":
|
case "6":
|
||||||
case "7":
|
case "7":
|
||||||
return String.fromCharCode(parseInt(a, 8));
|
return String.fromCharCode(parseInt(a, 8));
|
||||||
|
case "a":
|
||||||
|
return String.fromCharCode(7);
|
||||||
case "b":
|
case "b":
|
||||||
return "\b";
|
return "\b";
|
||||||
case "t":
|
case "t":
|
||||||
|
@ -120,6 +120,7 @@ import "./tests/SIGABA.mjs";
|
|||||||
import "./tests/ELFInfo.mjs";
|
import "./tests/ELFInfo.mjs";
|
||||||
import "./tests/Subsection.mjs";
|
import "./tests/Subsection.mjs";
|
||||||
import "./tests/CaesarBoxCipher.mjs";
|
import "./tests/CaesarBoxCipher.mjs";
|
||||||
|
import "./tests/UnescapeString.mjs";
|
||||||
import "./tests/LS47.mjs";
|
import "./tests/LS47.mjs";
|
||||||
import "./tests/LZString.mjs";
|
import "./tests/LZString.mjs";
|
||||||
|
|
||||||
|
55
tests/operations/tests/UnescapeString.mjs
Normal file
55
tests/operations/tests/UnescapeString.mjs
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
/**
|
||||||
|
* UnescapeString tests.
|
||||||
|
*
|
||||||
|
* @copyright Crown Copyright 2022
|
||||||
|
* @license Apache-2.0
|
||||||
|
*/
|
||||||
|
import TestRegister from "../../lib/TestRegister.mjs";
|
||||||
|
|
||||||
|
TestRegister.addTests([
|
||||||
|
{
|
||||||
|
name: "UnescapeString: escape sequences",
|
||||||
|
input: "\\a\\b\\f\\n\\r\\t\\v\\'\\\"",
|
||||||
|
expectedOutput: String.fromCharCode(0x07, 0x08, 0x0c, 0x0a, 0x0d, 0x09,
|
||||||
|
0x0b, 0x27, 0x22),
|
||||||
|
recipeConfig: [
|
||||||
|
{
|
||||||
|
op: "Unescape string",
|
||||||
|
args: [],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "UnescapeString: octals",
|
||||||
|
input: "\\0\\01\\012\\1\\12",
|
||||||
|
expectedOutput: String.fromCharCode(0, 1, 10, 1, 10),
|
||||||
|
recipeConfig: [
|
||||||
|
{
|
||||||
|
op: "Unescape string",
|
||||||
|
args: [],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "UnescapeString: hexadecimals",
|
||||||
|
input: "\\x00\\xAA\\xaa",
|
||||||
|
expectedOutput: String.fromCharCode(0, 170, 170),
|
||||||
|
recipeConfig: [
|
||||||
|
{
|
||||||
|
op: "Unescape string",
|
||||||
|
args: [],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "UnescapeString: unicode",
|
||||||
|
input: "\\u0061\\u{0062}",
|
||||||
|
expectedOutput: "ab",
|
||||||
|
recipeConfig: [
|
||||||
|
{
|
||||||
|
op: "Unescape string",
|
||||||
|
args: [],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
]);
|
Loading…
x
Reference in New Issue
Block a user