Title: [279666] trunk
Revision
279666
Author
[email protected]
Date
2021-07-07 13:59:59 -0700 (Wed, 07 Jul 2021)

Log Message

Allow setting empty hosts of URLs with non-special schemes
https://bugs.webkit.org/show_bug.cgi?id=227752

Reviewed by Chris Dumez.

LayoutTests/imported/w3c:

* web-platform-tests/url/url-setters-a-area.window-expected.txt:
* web-platform-tests/url/url-setters.any-expected.txt:
* web-platform-tests/url/url-setters.any.worker-expected.txt:

Source/WebCore:

asdf:/// is fine.
http:/// is not fine.

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

Modified Paths

Diff

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (279665 => 279666)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2021-07-07 20:50:19 UTC (rev 279665)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2021-07-07 20:59:59 UTC (rev 279666)
@@ -1,5 +1,16 @@
 2021-07-07  Alex Christensen  <[email protected]>
 
+        Allow setting empty hosts of URLs with non-special schemes
+        https://bugs.webkit.org/show_bug.cgi?id=227752
+
+        Reviewed by Chris Dumez.
+
+        * web-platform-tests/url/url-setters-a-area.window-expected.txt:
+        * web-platform-tests/url/url-setters.any-expected.txt:
+        * web-platform-tests/url/url-setters.any.worker-expected.txt:
+
+2021-07-07  Alex Christensen  <[email protected]>
+
         URL path setter should add "./" before non-empty path and after empty host for URLs with non-special schemes
         https://bugs.webkit.org/show_bug.cgi?id=227750
 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/url/url-setters-a-area.window-expected.txt (279665 => 279666)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/url/url-setters-a-area.window-expected.txt	2021-07-07 20:50:19 UTC (rev 279665)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/url/url-setters-a-area.window-expected.txt	2021-07-07 20:59:59 UTC (rev 279666)
@@ -148,8 +148,8 @@
 PASS <area>: Setting <http://example.net:8080>.host = 'example.com:' Port number is unchanged if not specified
 PASS <a>: Setting <http://example.net>.host = '' The empty host is not valid for special schemes
 PASS <area>: Setting <http://example.net>.host = '' The empty host is not valid for special schemes
-FAIL <a>: Setting <view-source+http://example.net/foo>.host = '' The empty host is OK for non-special schemes assert_equals: expected "view-source+http:///foo" but got "view-source+http://example.net/foo"
-FAIL <area>: Setting <view-source+http://example.net/foo>.host = '' The empty host is OK for non-special schemes assert_equals: expected "view-source+http:///foo" but got "view-source+http://example.net/foo"
+PASS <a>: Setting <view-source+http://example.net/foo>.host = '' The empty host is OK for non-special schemes
+PASS <area>: Setting <view-source+http://example.net/foo>.host = '' The empty host is OK for non-special schemes
 PASS <a>: Setting <a:/foo>.host = 'example.net' Path-only URLs can gain a host
 PASS <area>: Setting <a:/foo>.host = 'example.net' Path-only URLs can gain a host
 PASS <a>: Setting <http://example.net>.host = '0x7F000001:8080' IPv4 address syntax is normalized
@@ -232,8 +232,8 @@
 PASS <area>: Setting <sc://x/>.hostname = ' '
 PASS <a>: Setting <sc://x/>.hostname = '#'
 PASS <area>: Setting <sc://x/>.hostname = '#'
-FAIL <a>: Setting <sc://x/>.hostname = '/' assert_equals: expected "sc:///" but got "sc://x/"
-FAIL <area>: Setting <sc://x/>.hostname = '/' assert_equals: expected "sc:///" but got "sc://x/"
+PASS <a>: Setting <sc://x/>.hostname = '/'
+PASS <area>: Setting <sc://x/>.hostname = '/'
 PASS <a>: Setting <sc://x/>.hostname = '?'
 PASS <area>: Setting <sc://x/>.hostname = '?'
 PASS <a>: Setting <sc://x/>.hostname = '@'
@@ -246,8 +246,8 @@
 PASS <area>: Setting <http://example.net:8080>.hostname = 'example.com'
 PASS <a>: Setting <http://example.net>.hostname = '' The empty host is not valid for special schemes
 PASS <area>: Setting <http://example.net>.hostname = '' The empty host is not valid for special schemes
-FAIL <a>: Setting <view-source+http://example.net/foo>.hostname = '' The empty host is OK for non-special schemes assert_equals: expected "view-source+http:///foo" but got "view-source+http://example.net/foo"
-FAIL <area>: Setting <view-source+http://example.net/foo>.hostname = '' The empty host is OK for non-special schemes assert_equals: expected "view-source+http:///foo" but got "view-source+http://example.net/foo"
+PASS <a>: Setting <view-source+http://example.net/foo>.hostname = '' The empty host is OK for non-special schemes
+PASS <area>: Setting <view-source+http://example.net/foo>.hostname = '' The empty host is OK for non-special schemes
 PASS <a>: Setting <a:/foo>.hostname = 'example.net' Path-only URLs can gain a host
 PASS <area>: Setting <a:/foo>.hostname = 'example.net' Path-only URLs can gain a host
 PASS <a>: Setting <http://example.net:8080>.hostname = '0x7F000001' IPv4 address syntax is normalized
@@ -290,8 +290,8 @@
 PASS <area>: Setting <sc://test:12/>.hostname = ''
 PASS <a>: Setting <non-spec:/.//p>.hostname = 'h' Drop /. from path
 PASS <area>: Setting <non-spec:/.//p>.hostname = 'h' Drop /. from path
-FAIL <a>: Setting <non-spec:/.//p>.hostname = '' assert_equals: expected "non-spec:////p" but got "non-spec:/.//p"
-FAIL <area>: Setting <non-spec:/.//p>.hostname = '' assert_equals: expected "non-spec:////p" but got "non-spec:/.//p"
+PASS <a>: Setting <non-spec:/.//p>.hostname = ''
+PASS <area>: Setting <non-spec:/.//p>.hostname = ''
 FAIL <a>: Setting <http://example.com/>.hostname = '///bad.com' Leading / is not stripped assert_equals: expected "http://example.com/" but got "http://bad.com/"
 FAIL <area>: Setting <http://example.com/>.hostname = '///bad.com' Leading / is not stripped assert_equals: expected "http://example.com/" but got "http://bad.com/"
 FAIL <a>: Setting <sc://example.com/>.hostname = '///bad.com' Leading / is not stripped assert_equals: expected "sc:///" but got "sc://bad.com/"

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


--- trunk/LayoutTests/imported/w3c/web-platform-tests/url/url-setters.any-expected.txt	2021-07-07 20:50:19 UTC (rev 279665)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/url/url-setters.any-expected.txt	2021-07-07 20:59:59 UTC (rev 279666)
@@ -74,7 +74,7 @@
 PASS URL: Setting <http://example.net:8080>.host = 'example.com' Port number is unchanged if not specified in the new value
 PASS URL: Setting <http://example.net:8080>.host = 'example.com:' Port number is unchanged if not specified
 PASS URL: Setting <http://example.net>.host = '' The empty host is not valid for special schemes
-FAIL URL: Setting <view-source+http://example.net/foo>.host = '' The empty host is OK for non-special schemes assert_equals: expected "view-source+http:///foo" but got "view-source+http://example.net/foo"
+PASS URL: Setting <view-source+http://example.net/foo>.host = '' The empty host is OK for non-special schemes
 PASS URL: Setting <a:/foo>.host = 'example.net' Path-only URLs can gain a host
 PASS URL: Setting <http://example.net>.host = '0x7F000001:8080' IPv4 address syntax is normalized
 PASS URL: Setting <http://example.net>.host = '[::0:01]:2' IPv6 address syntax is normalized
@@ -116,7 +116,7 @@
 PASS URL: Setting <sc://x/>.hostname = '\r'
 PASS URL: Setting <sc://x/>.hostname = ' '
 PASS URL: Setting <sc://x/>.hostname = '#'
-FAIL URL: Setting <sc://x/>.hostname = '/' assert_equals: expected "sc:///" but got "sc://x/"
+PASS URL: Setting <sc://x/>.hostname = '/'
 PASS URL: Setting <sc://x/>.hostname = '?'
 PASS URL: Setting <sc://x/>.hostname = '@'
 PASS URL: Setting <mailto:[email protected]>.hostname = 'example.com' Cannot-be-a-base means no host
@@ -123,7 +123,7 @@
 PASS URL: Setting <data:text/plain,Stuff>.hostname = 'example.net' Cannot-be-a-base means no host
 PASS URL: Setting <http://example.net:8080>.hostname = 'example.com'
 PASS URL: Setting <http://example.net>.hostname = '' The empty host is not valid for special schemes
-FAIL URL: Setting <view-source+http://example.net/foo>.hostname = '' The empty host is OK for non-special schemes assert_equals: expected "view-source+http:///foo" but got "view-source+http://example.net/foo"
+PASS URL: Setting <view-source+http://example.net/foo>.hostname = '' The empty host is OK for non-special schemes
 PASS URL: Setting <a:/foo>.hostname = 'example.net' Path-only URLs can gain a host
 PASS URL: Setting <http://example.net:8080>.hostname = '0x7F000001' IPv4 address syntax is normalized
 PASS URL: Setting <http://example.net>.hostname = '[::0:01]' IPv6 address syntax is normalized
@@ -145,7 +145,7 @@
 PASS URL: Setting <sc://test@test/>.hostname = ''
 PASS URL: Setting <sc://test:12/>.hostname = ''
 PASS URL: Setting <non-spec:/.//p>.hostname = 'h' Drop /. from path
-FAIL URL: Setting <non-spec:/.//p>.hostname = '' assert_equals: expected "non-spec:////p" but got "non-spec:/.//p"
+PASS URL: Setting <non-spec:/.//p>.hostname = ''
 FAIL URL: Setting <http://example.com/>.hostname = '///bad.com' Leading / is not stripped assert_equals: expected "http://example.com/" but got "http://bad.com/"
 FAIL URL: Setting <sc://example.com/>.hostname = '///bad.com' Leading / is not stripped assert_equals: expected "sc:///" but got "sc://bad.com/"
 PASS URL: Setting <http://example.net>.port = '8080'

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/url/url-setters.any.worker-expected.txt (279665 => 279666)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/url/url-setters.any.worker-expected.txt	2021-07-07 20:50:19 UTC (rev 279665)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/url/url-setters.any.worker-expected.txt	2021-07-07 20:59:59 UTC (rev 279666)
@@ -74,7 +74,7 @@
 PASS URL: Setting <http://example.net:8080>.host = 'example.com' Port number is unchanged if not specified in the new value
 PASS URL: Setting <http://example.net:8080>.host = 'example.com:' Port number is unchanged if not specified
 PASS URL: Setting <http://example.net>.host = '' The empty host is not valid for special schemes
-FAIL URL: Setting <view-source+http://example.net/foo>.host = '' The empty host is OK for non-special schemes assert_equals: expected "view-source+http:///foo" but got "view-source+http://example.net/foo"
+PASS URL: Setting <view-source+http://example.net/foo>.host = '' The empty host is OK for non-special schemes
 PASS URL: Setting <a:/foo>.host = 'example.net' Path-only URLs can gain a host
 PASS URL: Setting <http://example.net>.host = '0x7F000001:8080' IPv4 address syntax is normalized
 PASS URL: Setting <http://example.net>.host = '[::0:01]:2' IPv6 address syntax is normalized
@@ -116,7 +116,7 @@
 PASS URL: Setting <sc://x/>.hostname = '\r'
 PASS URL: Setting <sc://x/>.hostname = ' '
 PASS URL: Setting <sc://x/>.hostname = '#'
-FAIL URL: Setting <sc://x/>.hostname = '/' assert_equals: expected "sc:///" but got "sc://x/"
+PASS URL: Setting <sc://x/>.hostname = '/'
 PASS URL: Setting <sc://x/>.hostname = '?'
 PASS URL: Setting <sc://x/>.hostname = '@'
 PASS URL: Setting <mailto:[email protected]>.hostname = 'example.com' Cannot-be-a-base means no host
@@ -123,7 +123,7 @@
 PASS URL: Setting <data:text/plain,Stuff>.hostname = 'example.net' Cannot-be-a-base means no host
 PASS URL: Setting <http://example.net:8080>.hostname = 'example.com'
 PASS URL: Setting <http://example.net>.hostname = '' The empty host is not valid for special schemes
-FAIL URL: Setting <view-source+http://example.net/foo>.hostname = '' The empty host is OK for non-special schemes assert_equals: expected "view-source+http:///foo" but got "view-source+http://example.net/foo"
+PASS URL: Setting <view-source+http://example.net/foo>.hostname = '' The empty host is OK for non-special schemes
 PASS URL: Setting <a:/foo>.hostname = 'example.net' Path-only URLs can gain a host
 PASS URL: Setting <http://example.net:8080>.hostname = '0x7F000001' IPv4 address syntax is normalized
 PASS URL: Setting <http://example.net>.hostname = '[::0:01]' IPv6 address syntax is normalized
@@ -145,7 +145,7 @@
 PASS URL: Setting <sc://test@test/>.hostname = ''
 PASS URL: Setting <sc://test:12/>.hostname = ''
 PASS URL: Setting <non-spec:/.//p>.hostname = 'h' Drop /. from path
-FAIL URL: Setting <non-spec:/.//p>.hostname = '' assert_equals: expected "non-spec:////p" but got "non-spec:/.//p"
+PASS URL: Setting <non-spec:/.//p>.hostname = ''
 FAIL URL: Setting <http://example.com/>.hostname = '///bad.com' Leading / is not stripped assert_equals: expected "http://example.com/" but got "http://bad.com/"
 FAIL URL: Setting <sc://example.com/>.hostname = '///bad.com' Leading / is not stripped assert_equals: expected "sc:///" but got "sc://bad.com/"
 PASS URL: Setting <http://example.net>.port = '8080'

Modified: trunk/Source/WebCore/ChangeLog (279665 => 279666)


--- trunk/Source/WebCore/ChangeLog	2021-07-07 20:50:19 UTC (rev 279665)
+++ trunk/Source/WebCore/ChangeLog	2021-07-07 20:59:59 UTC (rev 279666)
@@ -1,3 +1,18 @@
+2021-07-07  Alex Christensen  <[email protected]>
+
+        Allow setting empty hosts of URLs with non-special schemes
+        https://bugs.webkit.org/show_bug.cgi?id=227752
+
+        Reviewed by Chris Dumez.
+
+        asdf:/// is fine.
+        http:/// is not fine.
+
+        * html/URLDecomposition.cpp:
+        (WebCore::URLDecomposition::setHost):
+        (WebCore::URLDecomposition::setHostname):
+        (WebCore::URLDecomposition::hash const):
+
 2021-07-07  Ryosuke Niwa  <[email protected]>
 
         Deploy smart pointers in DOMWindow

Modified: trunk/Source/WebCore/html/URLDecomposition.cpp (279665 => 279666)


--- trunk/Source/WebCore/html/URLDecomposition.cpp	2021-07-07 20:50:19 UTC (rev 279665)
+++ trunk/Source/WebCore/html/URLDecomposition.cpp	2021-07-07 20:59:59 UTC (rev 279666)
@@ -97,7 +97,7 @@
 void URLDecomposition::setHost(StringView value)
 {
     auto fullURL = this->fullURL();
-    if (value.isEmpty() && !fullURL.protocolIs("file"))
+    if (value.isEmpty() && !fullURL.protocolIs("file") && fullURL.hasSpecialScheme())
         return;
 
     size_t separator = value.reverseFind(':');
@@ -150,7 +150,7 @@
 {
     auto fullURL = this->fullURL();
     auto host = removeAllLeadingSolidusCharacters(value);
-    if (host.isEmpty() && !fullURL.protocolIs("file"))
+    if (host.isEmpty() && !fullURL.protocolIs("file") && fullURL.hasSpecialScheme())
         return;
     if (fullURL.cannotBeABaseURL() || !fullURL.canSetHostOrPort())
         return;
@@ -229,9 +229,8 @@
 
 String URLDecomposition::hash() const
 {
-    // FIXME: Why convert this string to an atom here instead of just a string? Intentionally to save memory? An error?
     auto fullURL = this->fullURL();
-    return fullURL.fragmentIdentifier().isEmpty() ? emptyAtom() : fullURL.fragmentIdentifierWithLeadingNumberSign().toAtomString();
+    return fullURL.fragmentIdentifier().isEmpty() ? emptyString() : fullURL.fragmentIdentifierWithLeadingNumberSign().toString();
 }
 
 void URLDecomposition::setHash(StringView value)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to