summaryrefslogtreecommitdiff
path: root/netwerk
diff options
context:
space:
mode:
authorMoonchild <moonchild@palemoon.org>2021-11-04 18:34:19 +0000
committerMoonchild <moonchild@palemoon.org>2022-04-03 00:59:58 +0200
commitc68b10676f74a1a3080d90801bbe9880dd467f5d (patch)
tree55b019b8a09253fdbdd7d79bc4d76bf37cfad773 /netwerk
parent22fb62a1fefa6eddbebe04ff7726aa4739353d55 (diff)
downloaduxp-c68b10676f74a1a3080d90801bbe9880dd467f5d.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