diff options
author | Moonchild <moonchild@palemoon.org> | 2021-11-04 18:34:19 +0000 |
---|---|---|
committer | Moonchild <moonchild@palemoon.org> | 2021-11-05 11:36:00 +0000 |
commit | e76c2caa87645fae7db4dabc527f72cc624f90bc (patch) | |
tree | bd24af089e37a241a41b693ac4d1a00638884423 /netwerk | |
parent | 22f310bf5e3cccd7370a73a02ae08e9ef8a7aa7e (diff) | |
download | uxp-e76c2caa87645fae7db4dabc527f72cc624f90bc.tar.gz |
[network] Align IDN normalization with the current spec.
Diffstat (limited to 'netwerk')
-rw-r--r-- | netwerk/base/nsStandardURL.cpp | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/netwerk/base/nsStandardURL.cpp b/netwerk/base/nsStandardURL.cpp index e021bbf5fb..57337e480d 100644 --- a/netwerk/base/nsStandardURL.cpp +++ b/netwerk/base/nsStandardURL.cpp @@ -600,11 +600,24 @@ nsStandardURL::NormalizeIDN(const nsCSubstring &host, nsCString &result) return NS_OK; } + // If the input is an ACE encoded string it MUST be ASCII or it's malformed + // according to the spec. + if (!IsAsciiString(host) && isACE) { + return NS_ERROR_MALFORMED_URI; + } + // Even if it's already ACE, we must still call ConvertUTF8toACE in order // for the input normalization to take place. rv = gIDN->ConvertUTF8toACE(host, normalized); if (NS_FAILED(rv)) { - return rv; + return rv; + } + + // If the ASCII representation doesn't contain the xn-- token then we don't + // need to call ConvertToDisplayIDN as that would not change anything. + if (!StringBeginsWith(normalized, NS_LITERAL_CSTRING("xn--")) && + normalized.Find(NS_LITERAL_CSTRING(".xn--")) == kNotFound) { + return NS_OK; } // Finally, convert to IDN |