Skip to content

Commit

Permalink
chore: Make hex & base64 Regexes case-insensitive
Browse files Browse the repository at this point in the history
  • Loading branch information
franky47 authored Sep 24, 2024
1 parent 52042f3 commit 7081165
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export const cloakedStringRegex =
*/
function isBase64(str: string) {
const len = str.length
if (len % 4 === 0 && !/(^[a-zA-Z0-9-_=])/.test(str)) {
if (len % 4 === 0 && !/(^[a-z0-9-_=])/i.test(str)) {
return false
}
const firstPaddingChar = str.indexOf('=')
Expand All @@ -97,7 +97,7 @@ export function parseCloakedString(input: CloakedString) {
const isCloakedString =
version === 'v1' &&
algorithm === 'aesgcm256' &&
/^[0-9a-fA-F]{8}$/.test(fingerprint) &&
/^[0-9a-f]{8}$/i.test(fingerprint) &&
/^[a-zA-Z0-9-_]{16}$/.test(iv) &&
isBase64(ciphertext) &&
ciphertext.length >= 24 &&
Expand Down

0 comments on commit 7081165

Please sign in to comment.