From 78d1d5b6ab278814d876986473de99a63ff66ed0 Mon Sep 17 00:00:00 2001 From: daverayment Date: Tue, 4 Aug 2015 10:53:47 +0100 Subject: [PATCH] Fix base 64 character exclusion regex Using [A-z] in the regex brings in non-alphanumeric characters between the uppercase and lowercase alphabets, meaning the following chars were not correctly stripped from base 64 strings: left and right square bracket, backslash, caret, underline, and backtick. Explicitly separating the uppercase and lowercase letter ranges fixes this. --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index 7b7b02c..cf8a14c 100644 --- a/index.js +++ b/index.js @@ -1290,7 +1290,7 @@ Buffer._augment = function _augment (arr) { return arr } -var INVALID_BASE64_RE = /[^+\/0-9A-z\-]/g +var INVALID_BASE64_RE = /[^+\/0-9A-Za-z\-]/g function base64clean (str) { // Node strips out invalid characters like \n and \t from the string, base64-js does not -- 2.34.1