I think the problem is the same, there is an inconsistency in dealing with newline in javascript across browser. 
But, we could try the otherway arround which is checking wether the string contain any caracter other than `A-Za-z0-9+/=` and fail in this case. So we will have false positive (non base64 string that pass the test), but cannot have 'dangerous caracters' like `<&>`... and this will probably be also faster because the regex matching will return at the first bad char.