summaryrefslogtreecommitdiff
path: root/netwerk
diff options
context:
space:
mode:
authorJob Bautista <jobbautista9@protonmail.com>2022-06-22 16:38:14 +0800
committerJob Bautista <jobbautista9@protonmail.com>2022-06-22 16:38:14 +0800
commit26adb1ff4193fa5b53a8c5e01b4ea0be3677eff8 (patch)
tree6d9cb4fb851478ff196d469f2fb32e2b962bc58c /netwerk
parent6558fea8334ac8f001616781f991829fa2070f9c (diff)
downloaduxp-26adb1ff4193fa5b53a8c5e01b4ea0be3677eff8.tar.gz
Issue #326 - Part 1a: Update character property table generator script for Unicode 9, and adjust APIs to fit the new identifier-type property model
Backported from Mozilla bug 1281448.
Diffstat (limited to 'netwerk')
-rw-r--r--netwerk/dns/nsIDNService.cpp66
1 files changed, 33 insertions, 33 deletions
diff --git a/netwerk/dns/nsIDNService.cpp b/netwerk/dns/nsIDNService.cpp
index 9210e20b5f..70e255ed15 100644
--- a/netwerk/dns/nsIDNService.cpp
+++ b/netwerk/dns/nsIDNService.cpp
@@ -314,42 +314,42 @@ nsresult nsIDNService::ACEtoUTF8(const nsACString & input, nsACString & _retval,
return NS_OK;
}
-
-/**
- * Returns |true| if |aString| contains only ASCII characters according
- * to our CRT.
- *
- * @param aString an 8-bit wide string to scan
- */
-inline bool IsAsciiString(mozilla::Span<const char> aString) {
- for (char c : aString) {
- if (!nsCRT::IsAscii(c)) {
- return false;
- }
- }
- return true;
-}
+
+/**
+ * Returns |true| if |aString| contains only ASCII characters according
+ * to our CRT.
+ *
+ * @param aString an 8-bit wide string to scan
+ */
+inline bool IsAsciiString(mozilla::Span<const char> aString) {
+ for (char c : aString) {
+ if (!nsCRT::IsAscii(c)) {
+ return false;
+ }
+ }
+ return true;
+}
NS_IMETHODIMP nsIDNService::IsACE(const nsACString & input, bool *_retval)
{
// look for the ACE prefix in the input string. it may occur
// at the beginning of any segment in the domain name. for
// example: "www.xn--ENCODED.com"
- if (!IsAsciiString(input)) {
- *_retval = false;
- return NS_OK;
- }
- auto stringContains = [](const nsACString& haystack,
- const nsACString& needle) {
- return std::search(haystack.BeginReading(), haystack.EndReading(),
- needle.BeginReading(),
- needle.EndReading()) != haystack.EndReading();
- };
-
- *_retval = StringBeginsWith(input, NS_LITERAL_CSTRING("xn--")) ||
- (!input.IsEmpty() && input[0] != '.' &&
- stringContains(input, NS_LITERAL_CSTRING(".xn--")));
- return NS_OK;
+ if (!IsAsciiString(input)) {
+ *_retval = false;
+ return NS_OK;
+ }
+ auto stringContains = [](const nsACString& haystack,
+ const nsACString& needle) {
+ return std::search(haystack.BeginReading(), haystack.EndReading(),
+ needle.BeginReading(),
+ needle.EndReading()) != haystack.EndReading();
+ };
+
+ *_retval = StringBeginsWith(input, NS_LITERAL_CSTRING("xn--")) ||
+ (!input.IsEmpty() && input[0] != '.' &&
+ stringContains(input, NS_LITERAL_CSTRING(".xn--")));
+ return NS_OK;
}
NS_IMETHODIMP nsIDNService::Normalize(const nsACString & input,
@@ -730,11 +730,11 @@ bool nsIDNService::isLabelSafe(const nsAString &label)
// Check for restricted characters; aspirational scripts are NOT permitted,
// in anticipation of the category being merged into Limited-Use scripts
// in the upcoming (Unicode 10.0-based) revision of UAX #31.
- XidmodType xm = GetIdentifierModification(ch);
- if (xm != XIDMOD_RECOMMENDED &&
- xm != XIDMOD_INCLUSION) {
+ IdentifierType idType = GetIdentifierType(ch);
+ if (idType == IDTYPE_RESTRICTED) {
return false;
}
+ MOZ_ASSERT(idType == IDTYPE_ALLOWED || idType == IDTYPE_ASPIRATIONAL);
// Check for mixed script
Script script = GetScriptCode(ch);