mirror of
https://github.com/gchq/CyberChef
synced 2025-01-01 07:18:47 +00:00
Better delimeter parsing for From Base85
This commit is contained in:
parent
72889d1c20
commit
66cbc6908a
1 changed files with 9 additions and 2 deletions
|
@ -91,8 +91,11 @@ class FromBase85 extends Operation {
|
|||
|
||||
// Remove non-alphabet characters
|
||||
if (removeNonAlphChars) {
|
||||
const re = new RegExp("[^" + alphabet.replace(/[[\]\\\-^$]/g, "\\$&") + "]", "g");
|
||||
const re = new RegExp("[^" + "z~" +alphabet.replace(/[[\]\\\-^$]/g, "\\$&") + "]", "g");
|
||||
input = input.replace(re, "");
|
||||
// Remove delimiters again if present (incase of non-alphabet characters in front/behind delimiters)
|
||||
const matches = input.match(/^<~(.+?)~>$/);
|
||||
if (matches !== null) input = matches[1];
|
||||
}
|
||||
|
||||
if (input.length === 0) return [];
|
||||
|
@ -111,7 +114,11 @@ class FromBase85 extends Operation {
|
|||
.map((chr, idx) => {
|
||||
const digit = alphabet.indexOf(chr);
|
||||
if (digit < 0 || digit > 84) {
|
||||
throw `Invalid character '${chr}' at index ${i + idx}`;
|
||||
if (chr === "z"){
|
||||
// Pass (Ignore character)
|
||||
}else{
|
||||
throw `Invalid character '${chr}' at index ${i + idx}`;
|
||||
}
|
||||
}
|
||||
return digit;
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue