Skip to content

Commit cdb058a

Browse files
committed
Reject whitespace in armor without relying on scure-base
See paulmillr/scure-base#39.
1 parent 7ee46c6 commit cdb058a

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

lib/armor.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,5 +50,8 @@ export function decode(file: string): Uint8Array {
5050
if (!lines.every((l, i) => isLineLengthValid(i, l))) {
5151
throw Error("invalid line length")
5252
}
53+
if (!lines.every((l) => /^[A-Za-z0-9+/=]+$/.test(l))) {
54+
throw Error("invalid base64")
55+
}
5356
return base64.decode(lines.join(""))
5457
}

0 commit comments

Comments
 (0)