Title: [206784] trunk
Revision
206784
Author
[email protected]
Date
2016-10-04 14:22:34 -0700 (Tue, 04 Oct 2016)

Log Message

URLParser: query-only URLs relative to file URLs should just add a query
https://bugs.webkit.org/show_bug.cgi?id=162888

Reviewed by Tim Horton.

Source/WebCore:

Covered by new API tests.

* platform/URLParser.cpp:
(WebCore::URLParser::parse):
Like bug 206749 but with queries instead of fragments.

Tools:

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

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (206783 => 206784)


--- trunk/Source/WebCore/ChangeLog	2016-10-04 21:20:54 UTC (rev 206783)
+++ trunk/Source/WebCore/ChangeLog	2016-10-04 21:22:34 UTC (rev 206784)
@@ -1,5 +1,18 @@
 2016-10-04  Alex Christensen  <[email protected]>
 
+        URLParser: query-only URLs relative to file URLs should just add a query
+        https://bugs.webkit.org/show_bug.cgi?id=162888
+
+        Reviewed by Tim Horton.
+
+        Covered by new API tests.
+
+        * platform/URLParser.cpp:
+        (WebCore::URLParser::parse):
+        Like bug 206749 but with queries instead of fragments.
+
+2016-10-04  Alex Christensen  <[email protected]>
+
         URLParser should match URL::parse and other browsers when parsing a URL containing only scheme://
         https://bugs.webkit.org/show_bug.cgi?id=162909
 

Modified: trunk/Source/WebCore/platform/URLParser.cpp (206783 => 206784)


--- trunk/Source/WebCore/platform/URLParser.cpp	2016-10-04 21:20:54 UTC (rev 206783)
+++ trunk/Source/WebCore/platform/URLParser.cpp	2016-10-04 21:22:34 UTC (rev 206784)
@@ -1468,10 +1468,21 @@
                 break;
             case '?':
                 syntaxViolation(c);
-                if (base.isValid() && base.protocolIs("file"))
+                if (base.isValid() && base.protocolIs("file")) {
                     copyURLPartsUntil(base, URLPart::PathEnd, c);
-                appendToASCIIBuffer("///?", 4);
-                ++c;
+                    appendToASCIIBuffer('?');
+                    ++c;
+                } else {
+                    appendToASCIIBuffer("///?", 4);
+                    ++c;
+                    m_url.m_userStart = currentPosition(c) - 2;
+                    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 + 1;
+                    m_url.m_pathEnd = m_url.m_pathAfterLastSlash;
+                }
                 if (isUTF8Encoding)
                     state = State::UTF8Query;
                 else {
@@ -1478,13 +1489,6 @@
                     queryBegin = c;
                     state = State::NonUTF8Query;
                 }
-                m_url.m_userStart = currentPosition(c) - 2;
-                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 + 1;
-                m_url.m_pathEnd = m_url.m_pathAfterLastSlash;
                 break;
             case '#':
                 syntaxViolation(c);

Modified: trunk/Tools/ChangeLog (206783 => 206784)


--- trunk/Tools/ChangeLog	2016-10-04 21:20:54 UTC (rev 206783)
+++ trunk/Tools/ChangeLog	2016-10-04 21:22:34 UTC (rev 206784)
@@ -1,5 +1,15 @@
 2016-10-04  Alex Christensen  <[email protected]>
 
+        URLParser: query-only URLs relative to file URLs should just add a query
+        https://bugs.webkit.org/show_bug.cgi?id=162888
+
+        Reviewed by Tim Horton.
+
+        * TestWebKitAPI/Tests/WebCore/URLParser.cpp:
+        (TestWebKitAPI::TEST_F):
+
+2016-10-04  Alex Christensen  <[email protected]>
+
         URLParser should match URL::parse and other browsers when parsing a URL containing only scheme://
         https://bugs.webkit.org/show_bug.cgi?id=162909
 

Modified: trunk/Tools/TestWebKitAPI/Tests/WebCore/URLParser.cpp (206783 => 206784)


--- trunk/Tools/TestWebKitAPI/Tests/WebCore/URLParser.cpp	2016-10-04 21:20:54 UTC (rev 206783)
+++ trunk/Tools/TestWebKitAPI/Tests/WebCore/URLParser.cpp	2016-10-04 21:22:34 UTC (rev 206784)
@@ -398,6 +398,10 @@
     checkRelativeURL("#", "file:///path?query#old", {"file", "", "", "", 0, "/path", "query", "", "file:///path?query#"});
     checkRelativeURL("?query", "http://host/path", {"http", "", "", "host", 0, "/path", "query", "", "http://host/path?query"});
     checkRelativeURL("?query#fragment", "http://host/path", {"http", "", "", "host", 0, "/path", "query", "fragment", "http://host/path?query#fragment"});
+    checkRelativeURL("?new", "file:///path?old#fragment", {"file", "", "", "", 0, "/path", "new", "", "file:///path?new"});
+    checkRelativeURL("?", "file:///path?old#fragment", {"file", "", "", "", 0, "/path", "", "", "file:///path?"});
+    checkRelativeURL("?", "file:///path", {"file", "", "", "", 0, "/path", "", "", "file:///path?"});
+    checkRelativeURL("?query", "file:///path", {"file", "", "", "", 0, "/path", "query", "", "file:///path?query"});
     checkRelativeURL(utf16String(u"?β"), "http://example.org/foo/bar", {"http", "", "", "example.org", 0, "/foo/bar", "%CE%B2", "", "http://example.org/foo/bar?%CE%B2"});
     checkRelativeURL("?", "http://example.org/foo/bar", {"http", "", "", "example.org", 0, "/foo/bar", "", "", "http://example.org/foo/bar?"});
     checkRelativeURL("#", "http://example.org/foo/bar", {"http", "", "", "example.org", 0, "/foo/bar", "", "", "http://example.org/foo/bar#"});
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to