From fe8049199a1a08026c52ea6bcba53e00bb604944 Mon Sep 17 00:00:00 2001 From: n1474335 Date: Fri, 24 Nov 2017 16:32:11 +0000 Subject: [PATCH] Moved PhpDeserialize.js to PHP.js to encompass possible future PHP-related ops --- src/core/config/Categories.js | 2 +- src/core/config/OperationConfig.js | 6 +++--- src/core/config/modules/Default.js | 4 ++-- .../{PhpSerialization.js => PHP.js} | 20 ++++++++++--------- test/index.js | 2 +- .../{PhpSerialization.js => PHP.js} | 2 +- 6 files changed, 19 insertions(+), 17 deletions(-) rename src/core/operations/{PhpSerialization.js => PHP.js} (91%) rename test/tests/operations/{PhpSerialization.js => PHP.js} (98%) diff --git a/src/core/config/Categories.js b/src/core/config/Categories.js index 09f0187..3bc672b 100755 --- a/src/core/config/Categories.js +++ b/src/core/config/Categories.js @@ -66,7 +66,6 @@ const Categories = [ "Encode text", "Decode text", "Swap endianness", - "PHP Deserialize", ] }, { @@ -289,6 +288,7 @@ const Categories = [ "XPath expression", "JPath expression", "CSS selector", + "PHP Deserialize", "Microsoft Script Decoder", "Strip HTML tags", "Diff", diff --git a/src/core/config/OperationConfig.js b/src/core/config/OperationConfig.js index 469a98c..4307255 100755 --- a/src/core/config/OperationConfig.js +++ b/src/core/config/OperationConfig.js @@ -26,6 +26,7 @@ import JS from "../operations/JS.js"; import MAC from "../operations/MAC.js"; import MorseCode from "../operations/MorseCode.js"; import NetBIOS from "../operations/NetBIOS.js"; +import PHP from "../operations/PHP.js"; import PublicKey from "../operations/PublicKey.js"; import Punycode from "../operations/Punycode.js"; import Rotate from "../operations/Rotate.js"; @@ -35,7 +36,6 @@ import StrUtils from "../operations/StrUtils.js"; import Tidy from "../operations/Tidy.js"; import Unicode from "../operations/Unicode.js"; import URL_ from "../operations/URL.js"; -import PhpSerialization from "../operations/PhpSerialization.js"; /** @@ -3848,14 +3848,14 @@ const OperationConfig = { }, "PHP Deserialize": { module: "Default", - description: "PHP Deserialize a given input.

This function does not support object tags.

Output valid JSON: JSON doesn't support integers as keys, where as PHP serialization does. Enabling this will cast these integers to strings. This will also escape backslashes.", + description: "Deserializes PHP serialized data, outputting keyed arrays as JSON.

This function does not support object tags.

Example:
a:2:{s:1:"a";i:10;i:0;a:1:{s:2:"ab";b:1;}}
becomes
{"a": 10,0: {"ab": true}}

Output valid JSON: JSON doesn't support integers as keys, whereas PHP serialization does. Enabling this will cast these integers to strings. This will also escape backslashes.", inputType: "string", outputType: "string", args: [ { name: "Output valid JSON", type: "boolean", - value: PhpSerialization.OUTPUT_VALID_JSON + value: PHP.OUTPUT_VALID_JSON } ] }, diff --git a/src/core/config/modules/Default.js b/src/core/config/modules/Default.js index 8c13cfd..dec015a 100644 --- a/src/core/config/modules/Default.js +++ b/src/core/config/modules/Default.js @@ -20,6 +20,7 @@ import NetBIOS from "../../operations/NetBIOS.js"; import Numberwang from "../../operations/Numberwang.js"; import OS from "../../operations/OS.js"; import OTP from "../../operations/OTP.js"; +import PHP from "../../operations/PHP.js"; import QuotedPrintable from "../../operations/QuotedPrintable.js"; import Rotate from "../../operations/Rotate.js"; import SeqUtils from "../../operations/SeqUtils.js"; @@ -27,7 +28,6 @@ import StrUtils from "../../operations/StrUtils.js"; import Tidy from "../../operations/Tidy.js"; import Unicode from "../../operations/Unicode.js"; import UUID from "../../operations/UUID.js"; -import PhpSerialization from "../../operations/PhpSerialization"; /** * Default module. @@ -155,7 +155,7 @@ OpModules.Default = { "Conditional Jump": FlowControl.runCondJump, "Return": FlowControl.runReturn, "Comment": FlowControl.runComment, - "PHP Deserialize": PhpSerialization.PhpDeserialize, + "PHP Deserialize": PHP.runDeserialize, /* diff --git a/src/core/operations/PhpSerialization.js b/src/core/operations/PHP.js similarity index 91% rename from src/core/operations/PhpSerialization.js rename to src/core/operations/PHP.js index 3b2d8a2..e4bb0b5 100644 --- a/src/core/operations/PhpSerialization.js +++ b/src/core/operations/PHP.js @@ -1,8 +1,5 @@ /** - * Php Serialization operations. - * This Javascript implementation is based on the Python implementation by - * Armin Ronacher (2016), who released it under the 3-Clause BSD license. - * See: https://github.com/mitsuhiko/phpserialize/ + * PHP operations. * * @author Jarmo van Lenthe [github.com/jarmovanlenthe] * @copyright Jarmo van Lenthe @@ -10,8 +7,7 @@ * * @namespace */ - -const PhpSerialization = { +const PHP = { /** * @constant @@ -20,12 +16,17 @@ const PhpSerialization = { OUTPUT_VALID_JSON: true, /** - * Deserializes a PHP serialized input + * PHP Deserialize operation. + * + * This Javascript implementation is based on the Python implementation by + * Armin Ronacher (2016), who released it under the 3-Clause BSD license. + * See: https://github.com/mitsuhiko/phpserialize/ + * * @param {string} input * @param {Object[]} args * @returns {string} */ - PhpDeserialize: function (input, args) { + runDeserialize: function (input, args) { /** * Recursive method for deserializing. * @returns {*} @@ -153,6 +154,7 @@ const PhpSerialization = { let inputPart = input.split(""); return handleInput(); } + }; -export default PhpSerialization; +export default PHP; diff --git a/test/index.js b/test/index.js index 9fa4dcd..748e110 100644 --- a/test/index.js +++ b/test/index.js @@ -25,9 +25,9 @@ import "./tests/operations/Hash.js"; import "./tests/operations/Image.js"; import "./tests/operations/MorseCode.js"; import "./tests/operations/MS.js"; +import "./tests/operations/PHP.js"; import "./tests/operations/StrUtils.js"; import "./tests/operations/SeqUtils.js"; -import "./tests/operations/PhpSerialization.js"; let allTestsPassing = true; diff --git a/test/tests/operations/PhpSerialization.js b/test/tests/operations/PHP.js similarity index 98% rename from test/tests/operations/PhpSerialization.js rename to test/tests/operations/PHP.js index 8d745df..a42ee43 100644 --- a/test/tests/operations/PhpSerialization.js +++ b/test/tests/operations/PHP.js @@ -1,5 +1,5 @@ /** - * PHP Serialization tests. + * PHP tests. * * @author Jarmo van Lenthe *