cyberchef 9.47.4 → 9.47.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cyberchef",
3
- "version": "9.47.4",
3
+ "version": "9.47.5",
4
4
  "description": "The Cyber Swiss Army Knife for encryption, encoding, compression and data analysis.",
5
5
  "author": "n1474335 <n1474335@gmail.com>",
6
6
  "homepage": "https://gchq.github.io/CyberChef",
@@ -206,7 +206,7 @@ class Utils {
206
206
  * Utils.parseEscapedChars("\\n");
207
207
  */
208
208
  static parseEscapedChars(str) {
209
- 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) {
209
+ 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) {
210
210
  switch (a[0]) {
211
211
  case "\\":
212
212
  return "\\";
@@ -219,6 +219,8 @@ class Utils {
219
219
  case "6":
220
220
  case "7":
221
221
  return String.fromCharCode(parseInt(a, 8));
222
+ case "a":
223
+ return String.fromCharCode(7);
222
224
  case "b":
223
225
  return "\b";
224
226
  case "t":
@@ -120,6 +120,7 @@ import "./tests/SIGABA.mjs";
120
120
  import "./tests/ELFInfo.mjs";
121
121
  import "./tests/Subsection.mjs";
122
122
  import "./tests/CaesarBoxCipher.mjs";
123
+ import "./tests/UnescapeString.mjs";
123
124
  import "./tests/LS47.mjs";
124
125
  import "./tests/LZString.mjs";
125
126
 
@@ -0,0 +1,55 @@
1
+ /**
2
+ * UnescapeString tests.
3
+ *
4
+ * @copyright Crown Copyright 2022
5
+ * @license Apache-2.0
6
+ */
7
+ import TestRegister from "../../lib/TestRegister.mjs";
8
+
9
+ TestRegister.addTests([
10
+ {
11
+ name: "UnescapeString: escape sequences",
12
+ input: "\\a\\b\\f\\n\\r\\t\\v\\'\\\"",
13
+ expectedOutput: String.fromCharCode(0x07, 0x08, 0x0c, 0x0a, 0x0d, 0x09,
14
+ 0x0b, 0x27, 0x22),
15
+ recipeConfig: [
16
+ {
17
+ op: "Unescape string",
18
+ args: [],
19
+ },
20
+ ],
21
+ },
22
+ {
23
+ name: "UnescapeString: octals",
24
+ input: "\\0\\01\\012\\1\\12",
25
+ expectedOutput: String.fromCharCode(0, 1, 10, 1, 10),
26
+ recipeConfig: [
27
+ {
28
+ op: "Unescape string",
29
+ args: [],
30
+ },
31
+ ],
32
+ },
33
+ {
34
+ name: "UnescapeString: hexadecimals",
35
+ input: "\\x00\\xAA\\xaa",
36
+ expectedOutput: String.fromCharCode(0, 170, 170),
37
+ recipeConfig: [
38
+ {
39
+ op: "Unescape string",
40
+ args: [],
41
+ },
42
+ ],
43
+ },
44
+ {
45
+ name: "UnescapeString: unicode",
46
+ input: "\\u0061\\u{0062}",
47
+ expectedOutput: "ab",
48
+ recipeConfig: [
49
+ {
50
+ op: "Unescape string",
51
+ args: [],
52
+ },
53
+ ],
54
+ },
55
+ ]);