Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

toUnicode fails for malformed input #85

Open
sidonath opened this issue May 30, 2018 · 0 comments
Open

toUnicode fails for malformed input #85

sidonath opened this issue May 30, 2018 · 0 comments

Comments

@sidonath
Copy link

Hi there,

Thanks for developing and maintaining this package 🙇

Earlier today, I ran into a weird error when another script produced a malformed string which is not a punycode, but looks like one: "xn--http.com".

Per RFC 3490, toUnicode should never fail:

   ToUnicode never fails.  If any step fails, then the original input
   sequence is returned immediately in that step.

Unfortunately, this is not always the case with punycode.toUnicode:

> punycode.toUnicode('xn--http')
RangeError: Invalid input
    at error (punycode.js:42:8)
    at decode (punycode.js:235:5)
    at punycode.js:389:6
    at map (punycode.js:57:20)
    at mapDomain (punycode.js:84:18)
    at Object.toUnicode (punycode.js:387:9)

It would be great if punycode silently ignored exceptions and returned the given input.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant