mirror of
https://github.com/gchq/CyberChef.git
synced 2025-04-20 23:06:16 -04:00
Tidied up Base85 issues
This commit is contained in:
parent
b71e3241be
commit
2f097e5dfc
2 changed files with 11 additions and 7 deletions
|
@ -85,6 +85,10 @@ class FromBase85 extends Operation {
|
||||||
throw new OperationError("Alphabet must be of length 85");
|
throw new OperationError("Alphabet must be of length 85");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Remove delimiters if present
|
||||||
|
const matches = input.match(/^<~(.+?)~>$/);
|
||||||
|
if (matches !== null) input = matches[1];
|
||||||
|
|
||||||
// Remove non-alphabet characters
|
// Remove non-alphabet characters
|
||||||
if (removeNonAlphChars) {
|
if (removeNonAlphChars) {
|
||||||
const re = new RegExp("[^" + alphabet.replace(/[[\]\\\-^$]/g, "\\$&") + "]", "g");
|
const re = new RegExp("[^" + alphabet.replace(/[[\]\\\-^$]/g, "\\$&") + "]", "g");
|
||||||
|
@ -93,13 +97,6 @@ class FromBase85 extends Operation {
|
||||||
|
|
||||||
if (input.length === 0) return [];
|
if (input.length === 0) return [];
|
||||||
|
|
||||||
input = input.replace(/\s+/g, "");
|
|
||||||
|
|
||||||
if (encoding === "Standard") {
|
|
||||||
const matches = input.match(/<~(.+?)~>/);
|
|
||||||
if (matches !== null) input = matches[1];
|
|
||||||
}
|
|
||||||
|
|
||||||
let i = 0;
|
let i = 0;
|
||||||
let block, blockBytes;
|
let block, blockBytes;
|
||||||
while (i < input.length) {
|
while (i < input.length) {
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
import Chef from "../../src/core/Chef.mjs";
|
import Chef from "../../src/core/Chef.mjs";
|
||||||
import Utils from "../../src/core/Utils.mjs";
|
import Utils from "../../src/core/Utils.mjs";
|
||||||
import cliProgress from "cli-progress";
|
import cliProgress from "cli-progress";
|
||||||
|
import log from "loglevel";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Object to store and run the list of tests.
|
* Object to store and run the list of tests.
|
||||||
|
@ -50,6 +51,9 @@ class TestRegister {
|
||||||
* Runs all the tests in the register.
|
* Runs all the tests in the register.
|
||||||
*/
|
*/
|
||||||
async runTests () {
|
async runTests () {
|
||||||
|
// Turn off logging to avoid messy errors
|
||||||
|
log.setLevel("silent", false);
|
||||||
|
|
||||||
const progBar = new cliProgress.SingleBar({
|
const progBar = new cliProgress.SingleBar({
|
||||||
format: formatter,
|
format: formatter,
|
||||||
stopOnComplete: true
|
stopOnComplete: true
|
||||||
|
@ -128,6 +132,9 @@ class TestRegister {
|
||||||
progBar.increment();
|
progBar.increment();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Turn logging back on
|
||||||
|
log.setLevel("info", false);
|
||||||
|
|
||||||
return testResults;
|
return testResults;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue