summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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