Title: [206749] trunk
Revision
206749
Author
achristen...@apple.com
Date
2016-10-03 14:31:15 -0700 (Mon, 03 Oct 2016)

Log Message

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

Reviewed by Geoffrey Garen.

Source/WebCore:

Covered by new API tests.

* platform/URLParser.cpp:
(WebCore::URLParser::parse):
Instead of adding ///# after copying the base URL to the query, just add an #.

Tools:

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

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (206748 => 206749)


--- trunk/Source/WebCore/ChangeLog	2016-10-03 21:30:17 UTC (rev 206748)
+++ trunk/Source/WebCore/ChangeLog	2016-10-03 21:31:15 UTC (rev 206749)
@@ -1,3 +1,16 @@
+2016-10-03  Alex Christensen  <achristen...@webkit.org>
+
+        URLParser: fragment-only URLs relative to file URLs should just add a fragment
+        https://bugs.webkit.org/show_bug.cgi?id=162871
+
+        Reviewed by Geoffrey Garen.
+
+        Covered by new API tests.
+
+        * platform/URLParser.cpp:
+        (WebCore::URLParser::parse):
+        Instead of adding ///# after copying the base URL to the query, just add an #.
+
 2016-10-03  Antoine Quint  <grao...@apple.com>
 
         [Modern Media Controls] LayoutItem and Button classes

Modified: trunk/Source/WebCore/platform/URLParser.cpp (206748 => 206749)


--- trunk/Source/WebCore/platform/URLParser.cpp	2016-10-03 21:30:17 UTC (rev 206748)
+++ trunk/Source/WebCore/platform/URLParser.cpp	2016-10-03 21:31:15 UTC (rev 206749)
@@ -1461,17 +1461,20 @@
                 break;
             case '#':
                 syntaxViolation(c);
-                if (base.isValid() && base.protocolIs("file"))
+                if (base.isValid() && base.protocolIs("file")) {
                     copyURLPartsUntil(base, URLPart::QueryEnd, c);
-                appendToASCIIBuffer("///#", 4);
-                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;
-                m_url.m_queryEnd = m_url.m_pathAfterLastSlash;
+                    appendToASCIIBuffer('#');
+                } else {
+                    appendToASCIIBuffer("///#", 4);
+                    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;
+                    m_url.m_queryEnd = m_url.m_pathAfterLastSlash;
+                }
                 state = State::Fragment;
                 ++c;
                 break;

Modified: trunk/Tools/ChangeLog (206748 => 206749)


--- trunk/Tools/ChangeLog	2016-10-03 21:30:17 UTC (rev 206748)
+++ trunk/Tools/ChangeLog	2016-10-03 21:31:15 UTC (rev 206749)
@@ -1,3 +1,13 @@
+2016-10-03  Alex Christensen  <achristen...@webkit.org>
+
+        URLParser: fragment-only URLs relative to file URLs should just add a fragment
+        https://bugs.webkit.org/show_bug.cgi?id=162871
+
+        Reviewed by Geoffrey Garen.
+
+        * TestWebKitAPI/Tests/WebCore/URLParser.cpp:
+        (TestWebKitAPI::TEST_F):
+
 2016-10-03  Per Arne Vollan  <pvol...@apple.com>
 
         [Win] DRT temp folder is not used.

Modified: trunk/Tools/TestWebKitAPI/Tests/WebCore/URLParser.cpp (206748 => 206749)


--- trunk/Tools/TestWebKitAPI/Tests/WebCore/URLParser.cpp	2016-10-03 21:30:17 UTC (rev 206748)
+++ trunk/Tools/TestWebKitAPI/Tests/WebCore/URLParser.cpp	2016-10-03 21:31:15 UTC (rev 206749)
@@ -358,6 +358,13 @@
     checkRelativeURL(utf16String(u"http://www.foo。bar.com"), "http://other.com/", {"http", "", "", "www.foo.bar.com", 0, "/", "", "", "http://www.foo.bar.com/"});
     checkRelativeURL(utf16String(u"sc://ñ.test/"), "about:blank", {"sc", "", "", "xn--ida.test", 0, "/", "", "", "sc://xn--ida.test/"});
     checkRelativeURL("#fragment", "http://host/path", {"http", "", "", "host", 0, "/path", "", "fragment", "http://host/path#fragment"});
+    checkRelativeURL("#fragment", "file:///path", {"file", "", "", "", 0, "/path", "", "fragment", "file:///path#fragment"});
+    checkRelativeURL("#fragment", "file:///path#old", {"file", "", "", "", 0, "/path", "", "fragment", "file:///path#fragment"});
+    checkRelativeURL("#", "file:///path#old", {"file", "", "", "", 0, "/path", "", "", "file:///path#"});
+    checkRelativeURL("  ", "file:///path#old", {"file", "", "", "", 0, "/path", "", "", "file:///path"});
+    checkRelativeURL("#", "file:///path", {"file", "", "", "", 0, "/path", "", "", "file:///path#"});
+    checkRelativeURL("#", "file:///path?query", {"file", "", "", "", 0, "/path", "query", "", "file:///path?query#"});
+    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(utf16String(u"?β"), "http://example.org/foo/bar", {"http", "", "", "example.org", 0, "/foo/bar", "%CE%B2", "", "http://example.org/foo/bar?%CE%B2"});
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to