Title: [205589] releases/WebKitGTK/webkit-2.14
Revision
205589
Author
[email protected]
Date
2016-09-07 23:44:42 -0700 (Wed, 07 Sep 2016)

Log Message

Merge r205194 - URLParser should handle relative URLs that start with //
https://bugs.webkit.org/show_bug.cgi?id=161364

Reviewed by Darin Adler.

Source/WebCore:

Covered by an API test.

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

Tools:

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

Modified Paths

Diff

Modified: releases/WebKitGTK/webkit-2.14/Source/WebCore/ChangeLog (205588 => 205589)


--- releases/WebKitGTK/webkit-2.14/Source/WebCore/ChangeLog	2016-09-08 06:42:02 UTC (rev 205588)
+++ releases/WebKitGTK/webkit-2.14/Source/WebCore/ChangeLog	2016-09-08 06:44:42 UTC (rev 205589)
@@ -1,3 +1,15 @@
+2016-08-30  Alex Christensen  <[email protected]>
+
+        URLParser should handle relative URLs that start with //
+        https://bugs.webkit.org/show_bug.cgi?id=161364
+
+        Reviewed by Darin Adler.
+
+        Covered by an API test.
+
+        * platform/URLParser.cpp:
+        (WebCore::URLParser::parse):
+
 2016-08-30  Zalan Bujtas  <[email protected]>
 
         ASSERTION FAILED: opportunitiesInRun <= expansionOpportunityCount in WebCore::computeExpansionForJustifiedText

Modified: releases/WebKitGTK/webkit-2.14/Source/WebCore/platform/URLParser.cpp (205588 => 205589)


--- releases/WebKitGTK/webkit-2.14/Source/WebCore/platform/URLParser.cpp	2016-09-08 06:42:02 UTC (rev 205588)
+++ releases/WebKitGTK/webkit-2.14/Source/WebCore/platform/URLParser.cpp	2016-09-08 06:44:42 UTC (rev 205589)
@@ -297,6 +297,8 @@
             LOG_STATE("RelativeSlash");
             if (*c == '/' || *c == '\\') {
                 ++c;
+                copyURLPartsUntil(base, URLPart::SchemeEnd);
+                m_buffer.append("://");
                 state = State::SpecialAuthorityIgnoreSlashes;
             } else {
                 copyURLPartsUntil(base, URLPart::PortEnd);

Modified: releases/WebKitGTK/webkit-2.14/Tools/ChangeLog (205588 => 205589)


--- releases/WebKitGTK/webkit-2.14/Tools/ChangeLog	2016-09-08 06:42:02 UTC (rev 205588)
+++ releases/WebKitGTK/webkit-2.14/Tools/ChangeLog	2016-09-08 06:44:42 UTC (rev 205589)
@@ -1,3 +1,14 @@
+2016-08-30  Alex Christensen  <[email protected]>
+
+        URLParser should handle relative URLs that start with //
+        https://bugs.webkit.org/show_bug.cgi?id=161364
+
+        Reviewed by Darin Adler.
+
+        * TestWebKitAPI/Tests/WebCore/URLParser.cpp:
+        (TestWebKitAPI::checkRelativeURL):
+        (TestWebKitAPI::TEST_F):
+
 2016-08-29  Aakash Jain  <[email protected]>
 
         EWS patch status page should indicate bot corresponding to each status message

Modified: releases/WebKitGTK/webkit-2.14/Tools/TestWebKitAPI/Tests/WebCore/URLParser.cpp (205588 => 205589)


--- releases/WebKitGTK/webkit-2.14/Tools/TestWebKitAPI/Tests/WebCore/URLParser.cpp	2016-09-08 06:42:02 UTC (rev 205588)
+++ releases/WebKitGTK/webkit-2.14/Tools/TestWebKitAPI/Tests/WebCore/URLParser.cpp	2016-09-08 06:44:42 UTC (rev 205589)
@@ -132,6 +132,7 @@
     checkRelativeURL("/index.html", "http://webkit.org/path1/path2/", {"http", "", "", "webkit.org", 0, "/index.html", "", "", "http://webkit.org/index.html"});
     checkRelativeURL("http://whatwg.org/index.html", "http://webkit.org/path1/path2/", {"http", "", "", "whatwg.org", 0, "/index.html", "", "", "http://whatwg.org/index.html"});
     checkRelativeURL("index.html", "http://webkit.org/path1/path2/page.html?query#fragment", {"http", "", "", "webkit.org", 0, "/path1/path2/index.html", "", "", "http://webkit.org/path1/path2/index.html"});
+    checkRelativeURL("//whatwg.org/index.html", "https://www.webkit.org/path", {"https", "", "", "whatwg.org", 0, "/index.html", "", "", "https://whatwg.org/index.html"});
 }
 
 static void checkURLDifferences(const String& urlString, const ExpectedParts& partsNew, const ExpectedParts& partsOld)
@@ -162,6 +163,37 @@
     EXPECT_FALSE(URLParser::allValuesEqual(url, oldURL));
 }
 
+static void checkRelativeURLDifferences(const String& urlString, const String& baseURLString, const ExpectedParts& partsNew, const ExpectedParts& partsOld)
+{
+    URLParser baseParser;
+    auto base = baseParser.parse(baseURLString);
+    
+    URLParser parser;
+    auto url = "" base);
+    EXPECT_TRUE(eq(partsNew.protocol, url.protocol()));
+    EXPECT_TRUE(eq(partsNew.user, url.user()));
+    EXPECT_TRUE(eq(partsNew.password, url.pass()));
+    EXPECT_TRUE(eq(partsNew.host, url.host()));
+    EXPECT_EQ(partsNew.port, url.port());
+    EXPECT_TRUE(eq(partsNew.path, url.path()));
+    EXPECT_TRUE(eq(partsNew.query, url.query()));
+    EXPECT_TRUE(eq(partsNew.fragment, url.fragmentIdentifier()));
+    EXPECT_TRUE(eq(partsNew.string, url.string()));
+    
+    auto oldURL = URL(URL(URL(), baseURLString), urlString);
+    EXPECT_TRUE(eq(partsOld.protocol, oldURL.protocol()));
+    EXPECT_TRUE(eq(partsOld.user, oldURL.user()));
+    EXPECT_TRUE(eq(partsOld.password, oldURL.pass()));
+    EXPECT_TRUE(eq(partsOld.host, oldURL.host()));
+    EXPECT_EQ(partsOld.port, oldURL.port());
+    EXPECT_TRUE(eq(partsOld.path, oldURL.path()));
+    EXPECT_TRUE(eq(partsOld.query, oldURL.query()));
+    EXPECT_TRUE(eq(partsOld.fragment, oldURL.fragmentIdentifier()));
+    EXPECT_TRUE(eq(partsOld.string, oldURL.string()));
+    
+    EXPECT_FALSE(URLParser::allValuesEqual(url, oldURL));
+}
+
 TEST_F(URLParserTest, ParserDifferences)
 {
     checkURLDifferences("http://127.0.1",
@@ -170,6 +202,12 @@
     checkURLDifferences("http://011.11.0X11.0x011",
         {"http", "", "", "9.11.17.17", 0, "/", "", "", "http://9.11.17.17/"},
         {"http", "", "", "011.11.0x11.0x011", 0, "/", "", "", "http://011.11.0x11.0x011/"});
+
+    // FIXME: This behavior ought to be specified in the standard.
+    // With the existing URL::parse, WebKit returns "https:/", Firefox returns "https:///", and Chrome throws an error.
+    checkRelativeURLDifferences("//", "https://www.webkit.org/path",
+        {"https", "", "", "", 0, "", "", "", "https://"},
+        {"https", "", "", "", 0, "/", "", "", "https:/"});
 }
 
 static void shouldFail(const String& urlString)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to