proposal-arraybuffer-base64 icon indicating copy to clipboard operation
proposal-arraybuffer-base64 copied to clipboard

FromHex should ignore odd number of trailing ignored characters

Open anba opened this issue 1 year ago • 1 comments

FromHex currently requires that the number of characters is not odd, even when the trailing characters are ignored, whereas FromBase64 ignores all trailing characters.

Suggested change to match FromBase64:

-      1. If _length_ modulo 2 is not 0, throw a *SyntaxError* exception.
+      1. If _length_ / 2 < _maxLength_ and _length_ modulo 2 is not 0, throw a *SyntaxError* exception.

anba avatar Feb 06 '24 08:02 anba

FromBase64 ignores whitespace, so it's impossible for it to check that the length is reasonable, whereas FromHex does not, so it can be more aggressive. I guess I could change FromHex anyway?

bakkot avatar Feb 06 '24 16:02 bakkot