mirror of
https://github.com/gchq/CyberChef.git
synced 2024-11-02 06:01:02 +01:00
026e9ca9c3
The sequece is part of C and C++ standard, as well as protocol buffer encoding. - https://en.wikipedia.org/wiki/Escape_sequences_in_C - https://en.cppreference.com/w/cpp/language/escape - https://developers.google.com/protocol-buffers/docs/text-format-spec#string
56 lines
1.3 KiB
JavaScript
56 lines
1.3 KiB
JavaScript
/**
|
|
* 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: [],
|
|
},
|
|
],
|
|
},
|
|
]);
|