mirror of
https://github.com/gchq/CyberChef
synced 2025-01-12 04:28:53 +00:00
Add JSDoc to helper functions and reformat while true.
This commit is contained in:
parent
50a32e90d9
commit
29047c2481
1 changed files with 24 additions and 1 deletions
|
@ -26,7 +26,16 @@ const PhpSerialization = {
|
|||
* @returns {string}
|
||||
*/
|
||||
PhpDeserialize: function (input, args) {
|
||||
/**
|
||||
* Recursive method for deserializing.
|
||||
* @returns {*}
|
||||
*/
|
||||
function handleInput() {
|
||||
/**
|
||||
* Read `length` characters from the input, shifting them out the input.
|
||||
* @param length
|
||||
* @returns {string}
|
||||
*/
|
||||
function read(length) {
|
||||
let result = "";
|
||||
for (let idx = 0; idx < length; idx++) {
|
||||
|
@ -39,9 +48,14 @@ const PhpSerialization = {
|
|||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read characters from the input until `until` is found.
|
||||
* @param until
|
||||
* @returns {string}
|
||||
*/
|
||||
function readUntil(until) {
|
||||
let result = "";
|
||||
while (true) {
|
||||
for(;;) {
|
||||
let char = read(1);
|
||||
if (char === until) {
|
||||
break;
|
||||
|
@ -53,6 +67,11 @@ const PhpSerialization = {
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* Read characters from the input that must be equal to `expect`
|
||||
* @param expect
|
||||
* @returns {string}
|
||||
*/
|
||||
function expect(expect) {
|
||||
let result = read(expect.length);
|
||||
if (result !== expect) {
|
||||
|
@ -61,6 +80,10 @@ const PhpSerialization = {
|
|||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function to handle deserialized arrays.
|
||||
* @returns {Array}
|
||||
*/
|
||||
function handleArray() {
|
||||
let items = parseInt(readUntil(":"), 10) * 2;
|
||||
expect("{");
|
||||
|
|
Loading…
Reference in a new issue