Skip to content

Commit

Permalink
punycode.js doesn't map uppercase letters
Browse files Browse the repository at this point in the history
They follow a different RFC than the URL spec references, so we'll have to lowercase ourselves first.
  • Loading branch information
Sebmaster committed Apr 30, 2015
1 parent ecb445e commit a098afd
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/url.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ function parseHost(input, isUnicode) {
}

let domain = decodeURIComponent(input);
let asciiDomain = punycode.toASCII(domain);
let asciiDomain = punycode.toASCII(domain.toLowerCase());

This comment has been minimized.

Copy link
@mathiasbynens

mathiasbynens Apr 30, 2015

Hmm, isn’t .toLowerCase() still incorrect? It doesn’t perform full case folding as per the Unicode standard.

This comment has been minimized.

Copy link
@domenic

domenic Apr 30, 2015

Member

Isn't there a new Ecma 402 API that does that?

Also, if we fix this, I insist that we add a test case before doing so.

if (domain.search(/\u0000|\u0009|\u000A|\u000D|\u0020|#|%|\/|:|\?|@|\[|\\|\]/) !== -1) {
throw new TypeError("Invalid Host");
}
Expand Down

3 comments on commit a098afd

@domenic
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They follow a different RFC than the URL spec references, so we'll have to lowercase ourselves first.

This seems kind of bad. @mathiasbynens, is there an IDNA.js or similar?

@mathiasbynens
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@domenic
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oof, OK, that sounds like a lot of work. And @jcranmer's comment at mathiasbynens/todo#9 (comment) is not very heartening either.

Please sign in to comment.