Title: [206158] trunk
Revision
206158
Author
achristen...@apple.com
Date
2016-09-20 11:31:27 -0700 (Tue, 20 Sep 2016)

Log Message

URLParser: Fix parsing relative URLs with one slash after the scheme:
https://bugs.webkit.org/show_bug.cgi?id=162294

Reviewed by Tim Horton.

Source/WebCore:

This fixes the relatively-obscure case where a relative URL has the same special scheme as the base,
but there is only one slash after the scheme: at the beginning of the relative URL.  According to spec,
this should be interpreted the same as if the scheme: were not there.
For example, parsing "http:/example.com/" relative to "http://example.org/foo/bar" should be the same as
parsing "/example.com/" relative to "http://example.org/foo/bar".

Covered by a new API test.

* platform/URLParser.cpp:
(WebCore::URLParser::parse):

Tools:

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

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (206157 => 206158)


--- trunk/Source/WebCore/ChangeLog	2016-09-20 18:27:37 UTC (rev 206157)
+++ trunk/Source/WebCore/ChangeLog	2016-09-20 18:31:27 UTC (rev 206158)
@@ -1,5 +1,23 @@
 2016-09-20  Alex Christensen  <achristen...@webkit.org>
 
+        URLParser: Fix parsing relative URLs with one slash after the scheme:
+        https://bugs.webkit.org/show_bug.cgi?id=162294
+
+        Reviewed by Tim Horton.
+
+        This fixes the relatively-obscure case where a relative URL has the same special scheme as the base,
+        but there is only one slash after the scheme: at the beginning of the relative URL.  According to spec,
+        this should be interpreted the same as if the scheme: were not there.
+        For example, parsing "http:/example.com/" relative to "http://example.org/foo/bar" should be the same as
+        parsing "/example.com/" relative to "http://example.org/foo/bar".
+
+        Covered by a new API test.
+
+        * platform/URLParser.cpp:
+        (WebCore::URLParser::parse):
+
+2016-09-20  Alex Christensen  <achristen...@webkit.org>
+
         Fix Windows file URL quirks in URLParser
         https://bugs.webkit.org/show_bug.cgi?id=162303
 

Modified: trunk/Source/WebCore/platform/URLParser.cpp (206157 => 206158)


--- trunk/Source/WebCore/platform/URLParser.cpp	2016-09-20 18:27:37 UTC (rev 206157)
+++ trunk/Source/WebCore/platform/URLParser.cpp	2016-09-20 18:31:27 UTC (rev 206158)
@@ -1063,7 +1063,8 @@
                     m_asciiBuffer.append('/');
                     state = State::SpecialAuthorityIgnoreSlashes;
                     ++c;
-                }
+                } else
+                    state = State::RelativeSlash;
             } else
                 state = State::Relative;
             break;

Modified: trunk/Tools/ChangeLog (206157 => 206158)


--- trunk/Tools/ChangeLog	2016-09-20 18:27:37 UTC (rev 206157)
+++ trunk/Tools/ChangeLog	2016-09-20 18:31:27 UTC (rev 206158)
@@ -1,5 +1,15 @@
 2016-09-20  Alex Christensen  <achristen...@webkit.org>
 
+        URLParser: Fix parsing relative URLs with one slash after the scheme:
+        https://bugs.webkit.org/show_bug.cgi?id=162294
+
+        Reviewed by Tim Horton.
+
+        * TestWebKitAPI/Tests/WebCore/URLParser.cpp:
+        (TestWebKitAPI::TEST_F):
+
+2016-09-20  Alex Christensen  <achristen...@webkit.org>
+
         Fix Windows file URL quirks in URLParser
         https://bugs.webkit.org/show_bug.cgi?id=162303
 

Modified: trunk/Tools/TestWebKitAPI/Tests/WebCore/URLParser.cpp (206157 => 206158)


--- trunk/Tools/TestWebKitAPI/Tests/WebCore/URLParser.cpp	2016-09-20 18:27:37 UTC (rev 206157)
+++ trunk/Tools/TestWebKitAPI/Tests/WebCore/URLParser.cpp	2016-09-20 18:31:27 UTC (rev 206158)
@@ -474,6 +474,9 @@
     checkURLDifferences("http:",
         {"http", "", "", "", 0, "", "", "", "http:"},
         {"http", "", "", "", 0, "/", "", "", "http:/"});
+    checkRelativeURLDifferences("http:/example.com/", "http://example.org/foo/bar",
+        {"http", "", "", "example.org", 0, "/example.com/", "", "", "http://example.org/example.com/"},
+        {"http", "", "", "example.com", 0, "/", "", "", "http://example.com/"});
     
     // This behavior matches Chrome and Firefox, but not WebKit using URL::parse.
     // The behavior of URL::parse is clearly wrong because reparsing file://path would make path the host.
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to