Title: [231110] trunk
Revision
231110
Author
[email protected]
Date
2018-04-27 12:44:02 -0700 (Fri, 27 Apr 2018)

Log Message

URL::appendEncodedHostName is using the deprecated uidna_IDNToASCII function
https://bugs.webkit.org/show_bug.cgi?id=184836

Patch by Christopher Reid <[email protected]> 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.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (231109 => 231110)


--- trunk/LayoutTests/ChangeLog	2018-04-27 19:34:54 UTC (rev 231109)
+++ trunk/LayoutTests/ChangeLog	2018-04-27 19:44:02 UTC (rev 231110)
@@ -1,3 +1,15 @@
+2018-04-27  Christopher Reid  <[email protected]>
+
+        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  <[email protected]>
 
         Use NetworkLoadChecker for XHR/fetch loads

Added: trunk/LayoutTests/fast/url/url-hostname-encoding-expected.txt (0 => 231110)


--- trunk/LayoutTests/fast/url/url-hostname-encoding-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/url/url-hostname-encoding-expected.txt	2018-04-27 19:44:02 UTC (rev 231110)
@@ -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
+

Added: trunk/LayoutTests/fast/url/url-hostname-encoding.html (0 => 231110)


--- trunk/LayoutTests/fast/url/url-hostname-encoding.html	                        (rev 0)
+++ trunk/LayoutTests/fast/url/url-hostname-encoding.html	2018-04-27 19:44:02 UTC (rev 231110)
@@ -0,0 +1,54 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+</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 = "" 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>

Modified: trunk/Source/WebCore/ChangeLog (231109 => 231110)


--- trunk/Source/WebCore/ChangeLog	2018-04-27 19:34:54 UTC (rev 231109)
+++ trunk/Source/WebCore/ChangeLog	2018-04-27 19:44:02 UTC (rev 231110)
@@ -1,3 +1,16 @@
+2018-04-27  Christopher Reid  <[email protected]>
+
+        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  <[email protected]>
 
         CachedRawResource is not handling incremental data computation correctly

Modified: trunk/Source/WebCore/platform/URL.cpp (231109 => 231110)


--- trunk/Source/WebCore/platform/URL.cpp	2018-04-27 19:34:54 UTC (rev 231109)
+++ trunk/Source/WebCore/platform/URL.cpp	2018-04-27 19:44:02 UTC (rev 231110)
@@ -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;
     }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to