URL::appendEncodedHostName is using the deprecated uidna_IDNToASCII function
https://bugs.webkit.org/show_bug.cgi?id=184836
Patch by Christopher Reid <chris.reid@sony.com> on 2018-04-27
Reviewed by Alex Christensen.
Source/WebCore:
Update URL::appendEncodedHostName to use uidna_nameToASCII as done in r208902.
Test: LayoutTests\fast\url\url-hostname-encoding.html
* platform/URL.cpp:
LayoutTests:
Verify that setting the host or hostname of URL objects will use IDNA2008.
* fast/url/url-hostname-encoding-expected.txt: Added.
* fast/url/url-hostname-encoding.html: Added.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@231110 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index bb0a5c0..465e8fa 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,15 @@
+2018-04-27 Christopher Reid <chris.reid@sony.com>
+
+ URL::appendEncodedHostName is using the deprecated uidna_IDNToASCII function
+ https://bugs.webkit.org/show_bug.cgi?id=184836
+
+ Reviewed by Alex Christensen.
+
+ Verify that setting the host or hostname of URL objects will use IDNA2008.
+
+ * fast/url/url-hostname-encoding-expected.txt: Added.
+ * fast/url/url-hostname-encoding.html: Added.
+
2018-04-27 Youenn Fablet <youenn@apple.com>
Use NetworkLoadChecker for XHR/fetch loads
diff --git a/LayoutTests/fast/url/url-hostname-encoding-expected.txt b/LayoutTests/fast/url/url-hostname-encoding-expected.txt
new file mode 100644
index 0000000..daf3f43
--- /dev/null
+++ b/LayoutTests/fast/url/url-hostname-encoding-expected.txt
@@ -0,0 +1,27 @@
+Test that setting the host and hostname attributes of URL objects uses IDNA2008.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS url.hostname is 'xn--bcher-kva.de'
+PASS url.hostname is 'xn--fa-hia.de'
+PASS url.hostname is 'xn--nxasmm1c.com'
+PASS url.hostname is 'xn--10cl1a0b660p.com'
+PASS url.hostname is 'xn--mgba3gch31f060k.com'
+PASS url.hostname is 'lookout.net'
+PASS url.hostname is 'google.com'
+PASS url.hostname is 'ss.com'
+PASS url.hostname is 'ss.foo.com'
+PASS url.host is 'xn--bcher-kva.de'
+PASS url.host is 'xn--fa-hia.de'
+PASS url.host is 'xn--nxasmm1c.com'
+PASS url.host is 'xn--10cl1a0b660p.com'
+PASS url.host is 'xn--mgba3gch31f060k.com'
+PASS url.host is 'lookout.net'
+PASS url.host is 'google.com'
+PASS url.host is 'ss.com'
+PASS url.host is 'ss.foo.com'
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/url/url-hostname-encoding.html b/LayoutTests/fast/url/url-hostname-encoding.html
new file mode 100644
index 0000000..72e2ff7
--- /dev/null
+++ b/LayoutTests/fast/url/url-hostname-encoding.html
@@ -0,0 +1,54 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src="../../resources/js-test.js"></script>
+</head>
+<body>
+<script>
+
+description('Test that setting the host and hostname attributes of URL objects uses IDNA2008.');
+
+// These cases are ones we conform to from idna2008.html
+cases = [
+ // For IDNA Compatibility test material see
+ // http://www.unicode.org/reports/tr46/
+ // http://www.unicode.org/Public/idna/latest/IdnaMappingTable.txt
+ // Deviant character tests (deviant processing behavior from IDNA2003)
+ ["B\u00FCcher.de","xn--bcher-kva.de"],
+ // The ß U+00DF LATIN SMALL LETTER SHARP S does NOT normalize to "ss" like it does during IDNA2003's mapping phase
+ ["fa\u00DF.de","xn--fa-hia.de"],
+ // The ς U+03C2 GREEK SMALL LETTER FINAL SIGMA using βόλος.com
+ ["\u03B2\u03CC\u03BB\u03BF\u03C2.com","xn--nxasmm1c.com"],
+ // The ZWJ U+200D ZERO WIDTH JOINER
+ ["\u0DC1\u0DCA\u200D\u0DBB\u0DD3.com","xn--10cl1a0b660p.com"],
+ // The ZWNJ U+200C ZERO WIDTH NON-JOINER
+ ["\u0646\u0627\u0645\u0647\u200C\u0627\u06CC.com","xn--mgba3gch31f060k.com"],
+ // Ignored characters should be removed * security risk
+ // U+034F COMBINING GRAPHEME JOINER
+ ["look\u034Fout.net","lookout.net"],
+ // Mapped characters
+ ["gOoGle.com","google.com"],
+ // 1E9E; mapped; 0073 0073
+ ["\u1E9E.com","ss.com"],
+ ["\u1E9E.foo.com","ss.foo.com"],
+];
+
+var url = new URL("http://www.webkit.org");
+
+for (var i = 0; i < cases.length; ++i) {
+ test_vector = cases[i][0];
+ expected_result = cases[i][1];
+ url.hostname = test_vector;
+ shouldBe("url.hostname", "'" + expected_result + "'");
+}
+
+for (var i = 0; i < cases.length; ++i) {
+ test_vector = cases[i][0];
+ expected_result = cases[i][1];
+ url.host = test_vector;
+ shouldBe("url.host", "'" + expected_result + "'");
+}
+
+</script>
+</body>
+</html>
diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog
index 1a08c2f..8eda24b 100644
--- a/Source/WebCore/ChangeLog
+++ b/Source/WebCore/ChangeLog
@@ -1,3 +1,16 @@
+2018-04-27 Christopher Reid <chris.reid@sony.com>
+
+ URL::appendEncodedHostName is using the deprecated uidna_IDNToASCII function
+ https://bugs.webkit.org/show_bug.cgi?id=184836
+
+ Reviewed by Alex Christensen.
+
+ Update URL::appendEncodedHostName to use uidna_nameToASCII as done in r208902.
+
+ Test: LayoutTests\fast\url\url-hostname-encoding.html
+
+ * platform/URL.cpp:
+
2018-04-27 Youenn Fablet <youenn@apple.com>
CachedRawResource is not handling incremental data computation correctly
diff --git a/Source/WebCore/platform/URL.cpp b/Source/WebCore/platform/URL.cpp
index 749f32d..9900e55 100644
--- a/Source/WebCore/platform/URL.cpp
+++ b/Source/WebCore/platform/URL.cpp
@@ -415,18 +415,11 @@
UChar hostnameBuffer[hostnameBufferLength];
UErrorCode error = U_ZERO_ERROR;
+ UIDNAInfo processingDetails = UIDNA_INFO_INITIALIZER;
+ int32_t numCharactersConverted = uidna_nameToASCII(&URLParser::internationalDomainNameTranscoder(),
+ string.upconvertedCharacters(), string.length(), hostnameBuffer, hostnameBufferLength, &processingDetails, &error);
-#if COMPILER(GCC_OR_CLANG)
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
-#endif
- int32_t numCharactersConverted = uidna_IDNToASCII(string.upconvertedCharacters(), string.length(), hostnameBuffer,
- hostnameBufferLength, UIDNA_ALLOW_UNASSIGNED, 0, &error);
-#if COMPILER(GCC_OR_CLANG)
-#pragma GCC diagnostic pop
-#endif
-
- if (error == U_ZERO_ERROR) {
+ if (U_SUCCESS(error) && !processingDetails.errors) {
buffer.append(hostnameBuffer, numCharactersConverted);
return true;
}