cyberchef 9.38.6 → 9.38.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/core/lib/Base64.mjs +8 -7
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cyberchef",
|
|
3
|
-
"version": "9.38.
|
|
3
|
+
"version": "9.38.7",
|
|
4
4
|
"description": "The Cyber Swiss Army Knife for encryption, encoding, compression and data analysis.",
|
|
5
5
|
"author": "n1474335 <n1474335@gmail.com>",
|
|
6
6
|
"homepage": "https://gchq.github.io/CyberChef",
|
package/src/core/lib/Base64.mjs
CHANGED
|
@@ -130,10 +130,11 @@ export function fromBase64(data, alphabet="A-Za-z0-9+/=", returnType="string", r
|
|
|
130
130
|
i = 0;
|
|
131
131
|
|
|
132
132
|
while (i < data.length) {
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
133
|
+
// Including `|| null` forces empty strings to null so that indexOf returns -1 instead of 0
|
|
134
|
+
enc1 = alphabet.indexOf(data.charAt(i++) || null);
|
|
135
|
+
enc2 = alphabet.indexOf(data.charAt(i++) || null);
|
|
136
|
+
enc3 = alphabet.indexOf(data.charAt(i++) || null);
|
|
137
|
+
enc4 = alphabet.indexOf(data.charAt(i++) || null);
|
|
137
138
|
|
|
138
139
|
if (strictMode && (enc1 < 0 || enc2 < 0 || enc3 < 0 || enc4 < 0)) {
|
|
139
140
|
throw new OperationError("Error: Base64 input contains non-alphabet char(s)");
|
|
@@ -143,13 +144,13 @@ export function fromBase64(data, alphabet="A-Za-z0-9+/=", returnType="string", r
|
|
|
143
144
|
chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
|
|
144
145
|
chr3 = ((enc3 & 3) << 6) | enc4;
|
|
145
146
|
|
|
146
|
-
if (chr1 < 256) {
|
|
147
|
+
if (chr1 >= 0 && chr1 < 256) {
|
|
147
148
|
output.push(chr1);
|
|
148
149
|
}
|
|
149
|
-
if (chr2 < 256 && enc3 !== 64) {
|
|
150
|
+
if (chr2 >= 0 && chr2 < 256 && enc3 !== 64) {
|
|
150
151
|
output.push(chr2);
|
|
151
152
|
}
|
|
152
|
-
if (chr3 < 256 && enc4 !== 64) {
|
|
153
|
+
if (chr3 >= 0 && chr3 < 256 && enc4 !== 64) {
|
|
153
154
|
output.push(chr3);
|
|
154
155
|
}
|
|
155
156
|
}
|