Skip to content

Commit

Permalink
url: ignore IDN errors when domainname have hyphens
Browse files Browse the repository at this point in the history
There are valid domain names with hyphens at 3 and 4th position, new
node WHATWG URL parser was failing for it assume its an invalid IDN.
Also filters IDN errors when domain label start or end with hyphen.

Fixes: nodejs#12965
Refs: https://www.icann.org/news/announcement-2000-01-07-en
  • Loading branch information
zimbabao committed May 19, 2017
1 parent 9dee867 commit 311667b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/node_i18n.cc
Original file line number Diff line number Diff line change
Expand Up @@ -472,8 +472,8 @@ int32_t ToUnicode(MaybeStackBuffer<char>* buf,
// 9.0.0 (rev. 17), but were found to be incompatible with many actual domain
// names in the wild. As such, in the current UTS #46 draft (rev. 18) these
// checks are made optional depending on the CheckHyphens flag, which will be
// disabled in WHATWG URL's "domain to ASCII" algorithm as soon as the UTS #46
// draft becomes standard.
// disabled in WHATWG URL's "domain to unicode" algorithm as soon as the UTS
// #46 draft becomes standard.
// Refs:
// - https://github.com/whatwg/url/issues/53
// - http://www.unicode.org/review/pri317/
Expand Down
8 changes: 8 additions & 0 deletions test/fixtures/url-idna.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,14 @@ module.exports = {
{
ascii: 'sn-a5mlrn7s-.gevideo.com',
unicode: 'sn-a5mlrn7s-.gevideo.com'
},
{
ascii: '-sn-a5mlrn7s-.gevideo.com',
unicode: '-sn-a5mlrn7s-.gevideo.com'
},
{
ascii: '-sn--a5mlrn7s-.gevideo.com',
unicode: '-sn--a5mlrn7s-.gevideo.com'
}
],
invalid: [
Expand Down

0 comments on commit 311667b

Please sign in to comment.