mirror of
https://github.com/gchq/CyberChef.git
synced 2025-04-20 14:56:19 -04:00
Corrections
This commit is contained in:
parent
4541d75f49
commit
dfd4cca43f
1 changed files with 11 additions and 9 deletions
|
@ -158,14 +158,15 @@ export default class Stream {
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Build's the skip forward table from the value to be searched.
|
* Builds the skip forward table from the value to be searched.
|
||||||
*
|
*
|
||||||
* @param val
|
* @param {Uint8Array} val
|
||||||
* @param len
|
* @param {Number} len
|
||||||
|
* @returns {Uint8Array}
|
||||||
*/
|
*/
|
||||||
function preprocess(val, len) {
|
function preprocess(val, len) {
|
||||||
const skiptable = new Array();
|
const skiptable = new Array();
|
||||||
val.forEach(function(element, index) {
|
val.forEach((element, index) => {
|
||||||
skiptable[element] = len - index;
|
skiptable[element] = len - index;
|
||||||
});
|
});
|
||||||
return skiptable;
|
return skiptable;
|
||||||
|
@ -189,8 +190,8 @@ export default class Stream {
|
||||||
found = true;
|
found = true;
|
||||||
|
|
||||||
// Loop through the elements comparing them to val.
|
// Loop through the elements comparing them to val.
|
||||||
for (let x = length-1; x+1; x--) {
|
for (let x = length-1; x > -1; x--) {
|
||||||
if (this.bytes[(this.position-length) + x] !== val[x]) {
|
if (this.bytes[this.position-length + x] !== val[x]) {
|
||||||
found = false;
|
found = false;
|
||||||
|
|
||||||
// If element is not equal to val's element then jump forward by the correct amount.
|
// If element is not equal to val's element then jump forward by the correct amount.
|
||||||
|
@ -199,7 +200,7 @@ export default class Stream {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (found) {
|
if (found) {
|
||||||
this.position = (this.position - length);
|
this.position -= length;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -209,10 +210,11 @@ export default class Stream {
|
||||||
/**
|
/**
|
||||||
* Consume bytes if it matches the supplied value.
|
* Consume bytes if it matches the supplied value.
|
||||||
*
|
*
|
||||||
* @param val
|
* @param {Number} val
|
||||||
*/
|
*/
|
||||||
consumeWhile(val) {
|
consumeWhile(val) {
|
||||||
while ((this.position < this.length) && (this.bytes[this.position++] === val));
|
while ((this.position < this.length) && (this.bytes[(this.position++)] === val))
|
||||||
|
this.position--;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue