Skip to content

Commit

Permalink
url: ignore IDN errors when domainname have two 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.

Fixes: nodejs#12965
  • Loading branch information
zimbabao committed May 19, 2017
1 parent 9516aa1 commit 2ee246f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/node_i18n.cc
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,7 @@ int32_t ToASCII(MaybeStackBuffer<char>* buf,
info.errors &= ~UIDNA_ERROR_EMPTY_LABEL;
info.errors &= ~UIDNA_ERROR_LABEL_TOO_LONG;
info.errors &= ~UIDNA_ERROR_DOMAIN_NAME_TOO_LONG;
info.errors &= ~UIDNA_ERROR_HYPHEN_3_4;

if (U_FAILURE(status) || (!lenient && info.errors != 0)) {
len = -1;
Expand Down
10 changes: 10 additions & 0 deletions test/parallel/test-url-parse-format.js
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,16 @@ const parseTests = {
path: '/bar'
},

'https://r4---sn-a5mlrn7s.gevideo.com/bar': {
href: 'https://r4---sn-a5mlrn7s.gevideo.com/bar',
host: 'r4---sn-a5mlrn7s.gevideo.com',
hostname: 'r4---sn-a5mlrn7s.gevideo.com',
protocol: 'https:',
slashes: true,
pathname: '/bar',
path: '/bar'
},

// IDNA tests
'http://www.日本語.com/': {
href: 'http://www.xn--wgv71a119e.com/',
Expand Down

0 comments on commit 2ee246f

Please sign in to comment.