Title: [205833] trunk
Revision
205833
Author
[email protected]
Date
2016-09-12 15:36:14 -0700 (Mon, 12 Sep 2016)

Log Message

URLParser: Correctly handle relative URLs that are just a scheme and a colon
https://bugs.webkit.org/show_bug.cgi?id=161876

Reviewed by Brady Eidson.

Source/WebCore:

Covered by new API tests.

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

Tools:

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

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (205832 => 205833)


--- trunk/Source/WebCore/ChangeLog	2016-09-12 22:35:20 UTC (rev 205832)
+++ trunk/Source/WebCore/ChangeLog	2016-09-12 22:36:14 UTC (rev 205833)
@@ -1,3 +1,15 @@
+2016-09-12  Alex Christensen  <[email protected]>
+
+        URLParser: Correctly handle relative URLs that are just a scheme and a colon
+        https://bugs.webkit.org/show_bug.cgi?id=161876
+
+        Reviewed by Brady Eidson.
+
+        Covered by new API tests.
+
+        * platform/URLParser.cpp:
+        (WebCore::URLParser::parse):
+
 2016-09-12  Dean Jackson  <[email protected]>
 
         Remove OptionalColor

Modified: trunk/Source/WebCore/platform/URLParser.cpp (205832 => 205833)


--- trunk/Source/WebCore/platform/URLParser.cpp	2016-09-12 22:35:20 UTC (rev 205832)
+++ trunk/Source/WebCore/platform/URLParser.cpp	2016-09-12 22:36:14 UTC (rev 205833)
@@ -576,9 +576,9 @@
                         m_url.m_cannotBeABaseURL = true;
                         state = State::CannotBeABaseURLPath;
                     }
-                    ++c;
-                    break;
                 }
+                ++c;
+                break;
             } else {
                 m_buffer.clear();
                 state = State::NoScheme;
@@ -968,6 +968,8 @@
         break;
     case State::SpecialRelativeOrAuthority:
         LOG_FINAL_STATE("SpecialRelativeOrAuthority");
+        copyURLPartsUntil(base, URLPart::QueryEnd);
+        m_url.m_fragmentEnd = m_url.m_queryEnd;
         break;
     case State::PathOrAuthority:
         LOG_FINAL_STATE("PathOrAuthority");
@@ -987,6 +989,15 @@
         break;
     case State::SpecialAuthoritySlashes:
         LOG_FINAL_STATE("SpecialAuthoritySlashes");
+        m_url.m_userStart = m_buffer.length();
+        m_url.m_userEnd = m_url.m_userStart;
+        m_url.m_passwordEnd = m_url.m_userStart;
+        m_url.m_hostEnd = m_url.m_userStart;
+        m_url.m_portEnd = m_url.m_userStart;
+        m_url.m_pathAfterLastSlash = m_url.m_userStart;
+        m_url.m_pathEnd = m_url.m_userStart;
+        m_url.m_queryEnd = m_url.m_userStart;
+        m_url.m_fragmentEnd = m_url.m_userStart;
         break;
     case State::SpecialAuthorityIgnoreSlashes:
         LOG_FINAL_STATE("SpecialAuthorityIgnoreSlashes");

Modified: trunk/Tools/ChangeLog (205832 => 205833)


--- trunk/Tools/ChangeLog	2016-09-12 22:35:20 UTC (rev 205832)
+++ trunk/Tools/ChangeLog	2016-09-12 22:36:14 UTC (rev 205833)
@@ -1,3 +1,13 @@
+2016-09-12  Alex Christensen  <[email protected]>
+
+        URLParser: Correctly handle relative URLs that are just a scheme and a colon
+        https://bugs.webkit.org/show_bug.cgi?id=161876
+
+        Reviewed by Brady Eidson.
+
+        * TestWebKitAPI/Tests/WebCore/URLParser.cpp:
+        (TestWebKitAPI::TEST_F):
+
 2016-09-12  DAN SAUNDERS  <[email protected]>
 
         AX: WKWebView for macOS does not allow configuration of tabsToLinks

Modified: trunk/Tools/TestWebKitAPI/Tests/WebCore/URLParser.cpp (205832 => 205833)


--- trunk/Tools/TestWebKitAPI/Tests/WebCore/URLParser.cpp	2016-09-12 22:35:20 UTC (rev 205832)
+++ trunk/Tools/TestWebKitAPI/Tests/WebCore/URLParser.cpp	2016-09-12 22:36:14 UTC (rev 205833)
@@ -274,6 +274,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://ExAmPlE.CoM", "http://other.com", {"http", "", "", "example.com", 0, "/", "", "", "http://example.com/"});
+    checkRelativeURL("http:", "http://example.org/foo/bar", {"http", "", "", "example.org", 0, "/foo/bar", "", "", "http://example.org/foo/bar"});
     
     // The checking of slashes in SpecialAuthoritySlashes needed to get this to pass contradicts what is in the spec,
     // but it is included in the web platform tests.
@@ -593,6 +594,11 @@
     checkURLDifferences("notspecial\t\t\n\t:\t\t\n\t/\t\t\n\t/\t\t\n\thost",
         {"notspecial", "", "", "host", 0, "/", "", "", "notspecial://host/"},
         {"notspecial", "", "", "host", 0, "", "", "", "notspecial://host"});
+    checkRelativeURL("http:", "http://example.org/foo/bar?query#fragment", {"http", "", "", "example.org", 0, "/foo/bar", "query", "", "http://example.org/foo/bar?query"});
+    checkRelativeURLDifferences("ws:", "http://example.org/foo/bar",
+        {"ws", "", "", "", 0, "", "", "", "ws:"},
+        {"ws", "", "", "", 0, "s:", "", "", "ws:s:"});
+    checkRelativeURL("notspecial:", "http://example.org/foo/bar", {"notspecial", "", "", "", 0, "", "", "", "notspecial:"});
 }
 
 } // namespace TestWebKitAPI
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to