summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMoonchild <moonchild@palemoon.org>2021-11-04 18:34:19 +0000
committerMoonchild <moonchild@palemoon.org>2022-04-04 22:05:33 +0200
commit497e453fe7df656758d6a8b09b5012a30ada5031 (patch)
treee982d13f10faaafec03bb418e2a3153d937a5753
parent7dec0edf50d49d388cbb864451c1378481da3b5d (diff)
downloaduxp-497e453fe7df656758d6a8b09b5012a30ada5031.tar.gz
[network] Align IDN normalization with the current spec.
-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