summaryrefslogtreecommitdiff
path: root/netwerk
diff options
context:
space:
mode:
authorMoonchild <moonchild@palemoon.org>2021-11-04 18:34:19 +0000
committerMoonchild <moonchild@palemoon.org>2021-11-05 11:36:00 +0000
commite76c2caa87645fae7db4dabc527f72cc624f90bc (patch)
treebd24af089e37a241a41b693ac4d1a00638884423 /netwerk
parent22f310bf5e3cccd7370a73a02ae08e9ef8a7aa7e (diff)
downloaduxp-e76c2caa87645fae7db4dabc527f72cc624f90bc.tar.gz
[network] Align IDN normalization with the current spec.
Diffstat (limited to 'netwerk')
-rw-r--r--netwerk/base/nsStandardURL.cpp15
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