mathiasbynens / punycode.js

A robust Punycode converter that fully complies to RFC 3492 and RFC 5891.
https://mths.be/punycode
MIT License
1.6k stars 159 forks source link

Do not decode non-ASCII-alphanumerics in Punycode labels #124

Closed karwa closed 1 year ago

karwa commented 1 year ago

Currently, invalid Punycode such as ls8h= will be successfully decoded. It should fail instead.

I think this comes about because basicToDigit was copied from C code in the punycode RFC, but that RFC uses unsigned integers, whereas JS only has signed integers (AFAIK). We need to check that the result of, say, codePoint - 0x30 is not negative -- or, as done here, check that codePoint >= 0x30.