tc39 / proposal-arraybuffer-base64

TC39 proposal for Uint8Array<->base64/hex
https://tc39.github.io/proposal-arraybuffer-base64/
MIT License
243 stars 8 forks source link

FromHex should ignore odd number of trailing ignored characters #50

Open anba opened 7 months ago

anba commented 7 months ago

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 &lt; _maxLength_ and _length_ modulo 2 is not 0, throw a *SyntaxError* exception.
bakkot commented 7 months ago

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?