Moved PhpDeserialize.js to PHP.js to encompass possible future PHP-related ops

This commit is contained in:
n1474335 2017-11-24 16:32:11 +00:00
parent cfb6dd9471
commit fe8049199a
6 changed files with 19 additions and 17 deletions

View file

@ -66,7 +66,6 @@ const Categories = [
"Encode text", "Encode text",
"Decode text", "Decode text",
"Swap endianness", "Swap endianness",
"PHP Deserialize",
] ]
}, },
{ {
@ -289,6 +288,7 @@ const Categories = [
"XPath expression", "XPath expression",
"JPath expression", "JPath expression",
"CSS selector", "CSS selector",
"PHP Deserialize",
"Microsoft Script Decoder", "Microsoft Script Decoder",
"Strip HTML tags", "Strip HTML tags",
"Diff", "Diff",

View file

@ -26,6 +26,7 @@ import JS from "../operations/JS.js";
import MAC from "../operations/MAC.js"; import MAC from "../operations/MAC.js";
import MorseCode from "../operations/MorseCode.js"; import MorseCode from "../operations/MorseCode.js";
import NetBIOS from "../operations/NetBIOS.js"; import NetBIOS from "../operations/NetBIOS.js";
import PHP from "../operations/PHP.js";
import PublicKey from "../operations/PublicKey.js"; import PublicKey from "../operations/PublicKey.js";
import Punycode from "../operations/Punycode.js"; import Punycode from "../operations/Punycode.js";
import Rotate from "../operations/Rotate.js"; import Rotate from "../operations/Rotate.js";
@ -35,7 +36,6 @@ import StrUtils from "../operations/StrUtils.js";
import Tidy from "../operations/Tidy.js"; import Tidy from "../operations/Tidy.js";
import Unicode from "../operations/Unicode.js"; import Unicode from "../operations/Unicode.js";
import URL_ from "../operations/URL.js"; import URL_ from "../operations/URL.js";
import PhpSerialization from "../operations/PhpSerialization.js";
/** /**
@ -3848,14 +3848,14 @@ const OperationConfig = {
}, },
"PHP Deserialize": { "PHP Deserialize": {
module: "Default", module: "Default",
description: "PHP Deserialize a given input.<br><br>This function does not support <code>object</code> tags.<br><br><u>Output valid JSON:</u> 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.<br><br>This function does not support <code>object</code> tags.<br><br>Example:<br><code>a:2:{s:1:&quot;a&quot;;i:10;i:0;a:1:{s:2:&quot;ab&quot;;b:1;}}</code><br>becomes<br><code>{&quot;a&quot;: 10,0: {&quot;ab&quot;: true}}</code><br><br><u>Output valid JSON:</u> 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", inputType: "string",
outputType: "string", outputType: "string",
args: [ args: [
{ {
name: "Output valid JSON", name: "Output valid JSON",
type: "boolean", type: "boolean",
value: PhpSerialization.OUTPUT_VALID_JSON value: PHP.OUTPUT_VALID_JSON
} }
] ]
}, },

View file

@ -20,6 +20,7 @@ import NetBIOS from "../../operations/NetBIOS.js";
import Numberwang from "../../operations/Numberwang.js"; import Numberwang from "../../operations/Numberwang.js";
import OS from "../../operations/OS.js"; import OS from "../../operations/OS.js";
import OTP from "../../operations/OTP.js"; import OTP from "../../operations/OTP.js";
import PHP from "../../operations/PHP.js";
import QuotedPrintable from "../../operations/QuotedPrintable.js"; import QuotedPrintable from "../../operations/QuotedPrintable.js";
import Rotate from "../../operations/Rotate.js"; import Rotate from "../../operations/Rotate.js";
import SeqUtils from "../../operations/SeqUtils.js"; import SeqUtils from "../../operations/SeqUtils.js";
@ -27,7 +28,6 @@ import StrUtils from "../../operations/StrUtils.js";
import Tidy from "../../operations/Tidy.js"; import Tidy from "../../operations/Tidy.js";
import Unicode from "../../operations/Unicode.js"; import Unicode from "../../operations/Unicode.js";
import UUID from "../../operations/UUID.js"; import UUID from "../../operations/UUID.js";
import PhpSerialization from "../../operations/PhpSerialization";
/** /**
* Default module. * Default module.
@ -155,7 +155,7 @@ OpModules.Default = {
"Conditional Jump": FlowControl.runCondJump, "Conditional Jump": FlowControl.runCondJump,
"Return": FlowControl.runReturn, "Return": FlowControl.runReturn,
"Comment": FlowControl.runComment, "Comment": FlowControl.runComment,
"PHP Deserialize": PhpSerialization.PhpDeserialize, "PHP Deserialize": PHP.runDeserialize,
/* /*

View file

@ -1,8 +1,5 @@
/** /**
* Php Serialization operations. * PHP 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/
* *
* @author Jarmo van Lenthe [github.com/jarmovanlenthe] * @author Jarmo van Lenthe [github.com/jarmovanlenthe]
* @copyright Jarmo van Lenthe * @copyright Jarmo van Lenthe
@ -10,8 +7,7 @@
* *
* @namespace * @namespace
*/ */
const PHP = {
const PhpSerialization = {
/** /**
* @constant * @constant
@ -20,12 +16,17 @@ const PhpSerialization = {
OUTPUT_VALID_JSON: true, 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 {string} input
* @param {Object[]} args * @param {Object[]} args
* @returns {string} * @returns {string}
*/ */
PhpDeserialize: function (input, args) { runDeserialize: function (input, args) {
/** /**
* Recursive method for deserializing. * Recursive method for deserializing.
* @returns {*} * @returns {*}
@ -153,6 +154,7 @@ const PhpSerialization = {
let inputPart = input.split(""); let inputPart = input.split("");
return handleInput(); return handleInput();
} }
}; };
export default PhpSerialization; export default PHP;

View file

@ -25,9 +25,9 @@ import "./tests/operations/Hash.js";
import "./tests/operations/Image.js"; import "./tests/operations/Image.js";
import "./tests/operations/MorseCode.js"; import "./tests/operations/MorseCode.js";
import "./tests/operations/MS.js"; import "./tests/operations/MS.js";
import "./tests/operations/PHP.js";
import "./tests/operations/StrUtils.js"; import "./tests/operations/StrUtils.js";
import "./tests/operations/SeqUtils.js"; import "./tests/operations/SeqUtils.js";
import "./tests/operations/PhpSerialization.js";
let allTestsPassing = true; let allTestsPassing = true;

View file

@ -1,5 +1,5 @@
/** /**
* PHP Serialization tests. * PHP tests.
* *
* @author Jarmo van Lenthe * @author Jarmo van Lenthe
* *