Title: [263971] trunk
Revision
263971
Author
[email protected]
Date
2020-07-06 09:51:41 -0700 (Mon, 06 Jul 2020)

Log Message

Allow setting empty host/hostname on URLs if they use file scheme
https://bugs.webkit.org/show_bug.cgi?id=213983

Patch by Rob Buis <[email protected]> on 2020-07-06
Reviewed by Alex Christensen.

LayoutTests/imported/w3c:

Update improved test expectation.

* web-platform-tests/url/url-setters-expected.txt:

Source/WebCore:

Allow setting empty host/hostname on URLs if they use file scheme [1, 2, 3].

Behavior matches Firefox.

[1] https://url.spec.whatwg.org/#dom-url-host
[2] https://url.spec.whatwg.org/#dom-url-hostname
[3] https://url.spec.whatwg.org/#host-state Step 1

Test: imported/w3c/web-platform-tests/url/url-setters.html

* html/URLDecomposition.cpp:
(WebCore::URLDecomposition::setHost):
(WebCore::URLDecomposition::setHostname):

Modified Paths

Diff

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (263970 => 263971)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2020-07-06 16:48:51 UTC (rev 263970)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2020-07-06 16:51:41 UTC (rev 263971)
@@ -1,3 +1,14 @@
+2020-07-06  Rob Buis  <[email protected]>
+
+        Allow setting empty host/hostname on URLs if they use file scheme
+        https://bugs.webkit.org/show_bug.cgi?id=213983
+
+        Reviewed by Alex Christensen.
+
+        Update improved test expectation.
+
+        * web-platform-tests/url/url-setters-expected.txt:
+
 2020-07-03  Youenn Fablet  <[email protected]>
 
         MediaRecorder should support peer connection remote video tracks

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/url/url-setters-expected.txt (263970 => 263971)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/url/url-setters-expected.txt	2020-07-06 16:48:51 UTC (rev 263970)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/url/url-setters-expected.txt	2020-07-06 16:51:41 UTC (rev 263971)
@@ -306,9 +306,9 @@
 PASS URL: Setting <file://y/>.host = 'loc%41lhost' 
 PASS <a>: Setting <file://y/>.host = 'loc%41lhost' 
 PASS <area>: Setting <file://y/>.host = 'loc%41lhost' 
-FAIL URL: Setting <file://hi/x>.host = '' assert_equals: expected "file:///x" but got "file://hi/x"
-FAIL <a>: Setting <file://hi/x>.host = '' assert_equals: expected "file:///x" but got "file://hi/x"
-FAIL <area>: Setting <file://hi/x>.host = '' assert_equals: expected "file:///x" but got "file://hi/x"
+PASS URL: Setting <file://hi/x>.host = '' 
+PASS <a>: Setting <file://hi/x>.host = '' 
+PASS <area>: Setting <file://hi/x>.host = '' 
 PASS URL: Setting <sc://test@test/>.host = '' 
 PASS <a>: Setting <sc://test@test/>.host = '' 
 PASS <area>: Setting <sc://test@test/>.host = '' 
@@ -411,9 +411,9 @@
 PASS URL: Setting <file://y/>.hostname = 'loc%41lhost' 
 PASS <a>: Setting <file://y/>.hostname = 'loc%41lhost' 
 PASS <area>: Setting <file://y/>.hostname = 'loc%41lhost' 
-FAIL URL: Setting <file://hi/x>.hostname = '' assert_equals: expected "file:///x" but got "file://hi/x"
-FAIL <a>: Setting <file://hi/x>.hostname = '' assert_equals: expected "file:///x" but got "file://hi/x"
-FAIL <area>: Setting <file://hi/x>.hostname = '' assert_equals: expected "file:///x" but got "file://hi/x"
+PASS URL: Setting <file://hi/x>.hostname = '' 
+PASS <a>: Setting <file://hi/x>.hostname = '' 
+PASS <area>: Setting <file://hi/x>.hostname = '' 
 PASS URL: Setting <sc://test@test/>.hostname = '' 
 PASS <a>: Setting <sc://test@test/>.hostname = '' 
 PASS <area>: Setting <sc://test@test/>.hostname = '' 

Modified: trunk/Source/WebCore/ChangeLog (263970 => 263971)


--- trunk/Source/WebCore/ChangeLog	2020-07-06 16:48:51 UTC (rev 263970)
+++ trunk/Source/WebCore/ChangeLog	2020-07-06 16:51:41 UTC (rev 263971)
@@ -1,3 +1,24 @@
+2020-07-06  Rob Buis  <[email protected]>
+
+        Allow setting empty host/hostname on URLs if they use file scheme
+        https://bugs.webkit.org/show_bug.cgi?id=213983
+
+        Reviewed by Alex Christensen.
+
+        Allow setting empty host/hostname on URLs if they use file scheme [1, 2, 3].
+
+        Behavior matches Firefox.
+
+        [1] https://url.spec.whatwg.org/#dom-url-host
+        [2] https://url.spec.whatwg.org/#dom-url-hostname
+        [3] https://url.spec.whatwg.org/#host-state Step 1
+
+        Test: imported/w3c/web-platform-tests/url/url-setters.html
+
+        * html/URLDecomposition.cpp:
+        (WebCore::URLDecomposition::setHost):
+        (WebCore::URLDecomposition::setHostname):
+
 2020-07-06  Matt Gilligan  <[email protected]>
 
         Update the user agent on iPadOS to use 11 to match macOS Safari
@@ -1125,7 +1146,6 @@
             - Make parse* member functions templates to allow factory parse functions to
               call them without upconverting.
             - Replace header guard with #pragma once.
-
 2020-07-03  Sam Weinig  <[email protected]>
 
         Cleanup ApplicationCacheManifestParser.h/cpp

Modified: trunk/Source/WebCore/html/URLDecomposition.cpp (263970 => 263971)


--- trunk/Source/WebCore/html/URLDecomposition.cpp	2020-07-06 16:48:51 UTC (rev 263970)
+++ trunk/Source/WebCore/html/URLDecomposition.cpp	2020-07-06 16:51:41 UTC (rev 263971)
@@ -95,7 +95,8 @@
 
 void URLDecomposition::setHost(StringView value)
 {
-    if (value.isEmpty())
+    auto fullURL = this->fullURL();
+    if (value.isEmpty() && !fullURL.protocolIs("file"))
         return;
 
     size_t separator = value.find(':');
@@ -102,7 +103,6 @@
     if (!separator)
         return;
 
-    auto fullURL = this->fullURL();
     if (fullURL.cannotBeABaseURL() || !fullURL.canSetHostOrPort())
         return;
 
@@ -146,10 +146,10 @@
 
 void URLDecomposition::setHostname(StringView value)
 {
+    auto fullURL = this->fullURL();
     auto host = removeAllLeadingSolidusCharacters(value);
-    if (host.isEmpty())
+    if (host.isEmpty() && !fullURL.protocolIs("file"))
         return;
-    auto fullURL = this->fullURL();
     if (fullURL.cannotBeABaseURL() || !fullURL.canSetHostOrPort())
         return;
     fullURL.setHost(host);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to