Title: [205774] trunk
Revision
205774
Author
achristen...@apple.com
Date
2016-09-09 16:39:11 -0700 (Fri, 09 Sep 2016)

Log Message

URLParser should convert ASCII hosts to lowercase
https://bugs.webkit.org/show_bug.cgi?id=161820

Reviewed by Geoffrey Garen.

Source/WebCore:

Covered by new API tests.

* platform/URLParser.cpp:
(WebCore::domainToASCII):
The fast path for domains that are already ASCII and do not need punycode encoding
should convert the domain to lowercase.
This matches behavior in URL::parse if isCanonicalHostnameLowercaseForScheme is true,
and RFC 5890.

Tools:

* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::TEST_F):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (205773 => 205774)


--- trunk/Source/WebCore/ChangeLog	2016-09-09 22:44:13 UTC (rev 205773)
+++ trunk/Source/WebCore/ChangeLog	2016-09-09 23:39:11 UTC (rev 205774)
@@ -1,3 +1,19 @@
+2016-09-09  Alex Christensen  <achristen...@webkit.org>
+
+        URLParser should convert ASCII hosts to lowercase
+        https://bugs.webkit.org/show_bug.cgi?id=161820
+
+        Reviewed by Geoffrey Garen.
+
+        Covered by new API tests.
+
+        * platform/URLParser.cpp:
+        (WebCore::domainToASCII):
+        The fast path for domains that are already ASCII and do not need punycode encoding
+        should convert the domain to lowercase.
+        This matches behavior in URL::parse if isCanonicalHostnameLowercaseForScheme is true,
+        and RFC 5890.
+
 2016-09-09  Myles C. Maxfield  <mmaxfi...@apple.com>
 
         Remove unused member of GlyphBuffer

Modified: trunk/Source/WebCore/platform/URLParser.cpp (205773 => 205774)


--- trunk/Source/WebCore/platform/URLParser.cpp	2016-09-09 22:44:13 UTC (rev 205773)
+++ trunk/Source/WebCore/platform/URLParser.cpp	2016-09-09 23:39:11 UTC (rev 205774)
@@ -1334,12 +1334,12 @@
 
     if (containsOnlyASCII(domain)) {
         if (domain.is8Bit())
-            return domain;
+            return domain.convertToASCIILowercase();
         Vector<LChar, hostnameBufferLength> buffer;
         size_t length = domain.length();
         buffer.reserveInitialCapacity(length);
         for (size_t i = 0; i < length; ++i)
-            buffer.append(domain[i]);
+            buffer.append(toASCIILower(domain[i]));
         return String(buffer.data(), length);
     }
     

Modified: trunk/Tools/ChangeLog (205773 => 205774)


--- trunk/Tools/ChangeLog	2016-09-09 22:44:13 UTC (rev 205773)
+++ trunk/Tools/ChangeLog	2016-09-09 23:39:11 UTC (rev 205774)
@@ -1,3 +1,13 @@
+2016-09-09  Alex Christensen  <achristen...@webkit.org>
+
+        URLParser should convert ASCII hosts to lowercase
+        https://bugs.webkit.org/show_bug.cgi?id=161820
+
+        Reviewed by Geoffrey Garen.
+
+        * TestWebKitAPI/Tests/WebCore/URLParser.cpp:
+        (TestWebKitAPI::TEST_F):
+
 2016-09-09  Ryan Haddad  <ryanhad...@apple.com>
 
         Unreviewed, rolling out r205759.

Modified: trunk/Tools/TestWebKitAPI/Tests/WebCore/URLParser.cpp (205773 => 205774)


--- trunk/Tools/TestWebKitAPI/Tests/WebCore/URLParser.cpp	2016-09-09 22:44:13 UTC (rev 205773)
+++ trunk/Tools/TestWebKitAPI/Tests/WebCore/URLParser.cpp	2016-09-09 23:39:11 UTC (rev 205774)
@@ -164,7 +164,10 @@
     checkURL("file://localhost/path", {"file", "", "", "", 0, "/path", "", "", "file:///path"});
     checkURL("file://localhost/", {"file", "", "", "", 0, "/", "", "", "file:///"});
     checkURL("file://localhost", {"file", "", "", "", 0, "/", "", "", "file:///"});
-    // FIXME: check file://lOcAlHoSt etc.
+    checkURL("file://lOcAlHoSt", {"file", "", "", "", 0, "/", "", "", "file:///"});
+    checkURL("file://lOcAlHoSt/", {"file", "", "", "", 0, "/", "", "", "file:///"});
+    checkURL("file:/pAtH/", {"file", "", "", "", 0, "/pAtH/", "", "", "file:///pAtH/"});
+    checkURL("file:/pAtH", {"file", "", "", "", 0, "/pAtH", "", "", "file:///pAtH"});
     checkURL("file:?query", {"file", "", "", "", 0, "/", "query", "", "file:///?query"});
     checkURL("file:#fragment", {"file", "", "", "", 0, "/", "", "fragment", "file:///#fragment"});
     checkURL("file:?query#fragment", {"file", "", "", "", 0, "/", "query", "fragment", "file:///?query#fragment"});
@@ -268,6 +271,7 @@
     checkRelativeURL("http:\\\\foo.com\\", "http://example.org/foo/bar", {"http", "", "", "foo.com", 0, "/", "", "", "http://foo.com/"});
     checkRelativeURL("http:\\\\foo.com/", "http://example.org/foo/bar", {"http", "", "", "foo.com", 0, "/", "", "", "http://foo.com/"});
     checkRelativeURL("http:\\\\foo.com", "http://example.org/foo/bar", {"http", "", "", "foo.com", 0, "/", "", "", "http://foo.com/"});
+    checkRelativeURL("http://ExAmPlE.CoM", "http://other.com", {"http", "", "", "example.com", 0, "/", "", "", "http://example.com/"});
 }
 
 static void checkURLDifferences(const String& urlString, const ExpectedParts& partsNew, const ExpectedParts& partsOld)
@@ -438,6 +442,12 @@
     checkURLDifferences("file:path",
         {"file", "", "", "", 0, "/path", "", "", "file:///path"},
         {"file", "", "", "", 0, "path", "", "", "file://path"});
+    checkURLDifferences("file:pAtH",
+        {"file", "", "", "", 0, "/pAtH", "", "", "file:///pAtH"},
+        {"file", "", "", "", 0, "pAtH", "", "", "file://pAtH"});
+    checkURLDifferences("file:pAtH/",
+        {"file", "", "", "", 0, "/pAtH/", "", "", "file:///pAtH"},
+        {"file", "", "", "", 0, "pAtH/", "", "", "file://pAtH"});
     
     // FIXME: Fix and test incomplete percent encoded characters in the middle and end of the input string.
     // FIXME: Fix and test percent encoded upper case characters in the host.
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to