Title: [264516] trunk
Revision
264516
Author
[email protected]
Date
2020-07-17 09:38:05 -0700 (Fri, 17 Jul 2020)

Log Message

Changing URL.host should not override port
https://bugs.webkit.org/show_bug.cgi?id=151613

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

LayoutTests/imported/w3c:

Update improved test result.

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

Source/WebCore:

When setting host, empty/incorrect port strings
should not change the existing port [1, 2].

Behavior matches Chrome and Firefox.

[1] https://url.spec.whatwg.org/#host-state Step 2.4
[2] https://url.spec.whatwg.org/#port-state Step 2.2

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

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

LayoutTests:

Adjust tests to expect the new behavior.

* fast/dom/DOMURL/set-href-attribute-host-expected.txt:
* fast/dom/DOMURL/set-href-attribute-host.html:
* fast/dom/HTMLAnchorElement/set-href-attribute-host-expected.txt:
* fast/dom/HTMLAnchorElement/set-href-attribute-host.html:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (264515 => 264516)


--- trunk/LayoutTests/ChangeLog	2020-07-17 16:10:34 UTC (rev 264515)
+++ trunk/LayoutTests/ChangeLog	2020-07-17 16:38:05 UTC (rev 264516)
@@ -1,3 +1,17 @@
+2020-07-17  Rob Buis  <[email protected]>
+
+        Changing URL.host should not override port
+        https://bugs.webkit.org/show_bug.cgi?id=151613
+
+        Reviewed by Alex Christensen.
+
+        Adjust tests to expect the new behavior.
+
+        * fast/dom/DOMURL/set-href-attribute-host-expected.txt:
+        * fast/dom/DOMURL/set-href-attribute-host.html:
+        * fast/dom/HTMLAnchorElement/set-href-attribute-host-expected.txt:
+        * fast/dom/HTMLAnchorElement/set-href-attribute-host.html:
+
 2020-07-17  Lauro Moura  <[email protected]>
 
         [GTK][WPE] Garden imported html failures

Modified: trunk/LayoutTests/fast/dom/DOMURL/set-href-attribute-host-expected.txt (264515 => 264516)


--- trunk/LayoutTests/fast/dom/DOMURL/set-href-attribute-host-expected.txt	2020-07-17 16:10:34 UTC (rev 264515)
+++ trunk/LayoutTests/fast/dom/DOMURL/set-href-attribute-host-expected.txt	2020-07-17 16:38:05 UTC (rev 264516)
@@ -14,9 +14,9 @@
 Set host with letters in port number
 PASS a.href is 'https://www.otherdomain.com:44/path/'
 Leading space in port number
-PASS a.href is 'https://www.otherdomain.com:0/path/'
+PASS a.href is 'https://www.otherdomain.com:8080/path/'
 Colon without port number
-PASS a.href is 'https://www.otherdomain.com:0/path/'
+PASS a.href is 'https://www.otherdomain.com:8080/path/'
 Set host to null
 PASS a.href is 'https://null:8080/path/'
 Set host to empty string

Modified: trunk/LayoutTests/fast/dom/DOMURL/set-href-attribute-host.html (264515 => 264516)


--- trunk/LayoutTests/fast/dom/DOMURL/set-href-attribute-host.html	2020-07-17 16:10:34 UTC (rev 264515)
+++ trunk/LayoutTests/fast/dom/DOMURL/set-href-attribute-host.html	2020-07-17 16:38:05 UTC (rev 264516)
@@ -46,13 +46,13 @@
 debug("Leading space in port number");
 a.href = ""
 a.host = "www.otherdomain.com: 443";
-shouldBe("a.href", "'https://www.otherdomain.com:0/path/'");
+shouldBe("a.href", "'https://www.otherdomain.com:8080/path/'");
 
 // Firefox 3.5.2 removed the port, clearly against the spec .
 debug("Colon without port number");
 a.href = ""
 a.host = "www.otherdomain.com:";
-shouldBe("a.href", "'https://www.otherdomain.com:0/path/'");
+shouldBe("a.href", "'https://www.otherdomain.com:8080/path/'");
 
 debug("Set host to null");
 a.href = ""

Modified: trunk/LayoutTests/fast/dom/HTMLAnchorElement/set-href-attribute-host-expected.txt (264515 => 264516)


--- trunk/LayoutTests/fast/dom/HTMLAnchorElement/set-href-attribute-host-expected.txt	2020-07-17 16:10:34 UTC (rev 264515)
+++ trunk/LayoutTests/fast/dom/HTMLAnchorElement/set-href-attribute-host-expected.txt	2020-07-17 16:38:05 UTC (rev 264516)
@@ -14,9 +14,9 @@
 Set host with letters in port number
 PASS a.href is 'https://www.otherdomain.com:44/path/'
 Leading space in port number
-PASS a.href is 'https://www.otherdomain.com:0/path/'
+PASS a.href is 'https://www.otherdomain.com:8080/path/'
 Colon without port number
-PASS a.href is 'https://www.otherdomain.com:0/path/'
+PASS a.href is 'https://www.otherdomain.com:8080/path/'
 Set host to null
 PASS a.href is 'https://null:8080/path/'
 Set host to empty string

Modified: trunk/LayoutTests/fast/dom/HTMLAnchorElement/set-href-attribute-host.html (264515 => 264516)


--- trunk/LayoutTests/fast/dom/HTMLAnchorElement/set-href-attribute-host.html	2020-07-17 16:10:34 UTC (rev 264515)
+++ trunk/LayoutTests/fast/dom/HTMLAnchorElement/set-href-attribute-host.html	2020-07-17 16:38:05 UTC (rev 264516)
@@ -44,13 +44,13 @@
 debug("Leading space in port number");
 a.href = ""
 a.host = "www.otherdomain.com: 443";
-shouldBe("a.href", "'https://www.otherdomain.com:0/path/'");
+shouldBe("a.href", "'https://www.otherdomain.com:8080/path/'");
 
 // Firefox 3.5.2 removed the port, clearly against the spec .
 debug("Colon without port number");
 a.href = ""
 a.host = "www.otherdomain.com:";
-shouldBe("a.href", "'https://www.otherdomain.com:0/path/'");
+shouldBe("a.href", "'https://www.otherdomain.com:8080/path/'");
 
 debug("Set host to null");
 a.href = ""

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (264515 => 264516)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2020-07-17 16:10:34 UTC (rev 264515)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2020-07-17 16:38:05 UTC (rev 264516)
@@ -1,3 +1,14 @@
+2020-07-17  Rob Buis  <[email protected]>
+
+        Changing URL.host should not override port
+        https://bugs.webkit.org/show_bug.cgi?id=151613
+
+        Reviewed by Alex Christensen.
+
+        Update improved test result.
+
+        * web-platform-tests/url/url-setters-expected.txt:
+
 2020-07-16  Chris Dumez  <[email protected]>
 
         Resync web-platform-tests/interfaces from upstream

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


--- trunk/LayoutTests/imported/w3c/web-platform-tests/url/url-setters-expected.txt	2020-07-17 16:10:34 UTC (rev 264515)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/url/url-setters-expected.txt	2020-07-17 16:38:05 UTC (rev 264516)
@@ -216,9 +216,9 @@
 PASS URL: Setting <http://example.net:8080>.host = 'example.com' Port number is unchanged if not specified in the new value 
 PASS <a>: Setting <http://example.net:8080>.host = 'example.com' Port number is unchanged if not specified in the new value 
 PASS <area>: Setting <http://example.net:8080>.host = 'example.com' Port number is unchanged if not specified in the new value 
-FAIL URL: Setting <http://example.net:8080>.host = 'example.com:' Port number is unchanged if not specified assert_equals: expected "http://example.com:8080/" but got "http://example.com:0/"
-FAIL <a>: Setting <http://example.net:8080>.host = 'example.com:' Port number is unchanged if not specified assert_equals: expected "http://example.com:8080/" but got "http://example.com:0/"
-FAIL <area>: Setting <http://example.net:8080>.host = 'example.com:' Port number is unchanged if not specified assert_equals: expected "http://example.com:8080/" but got "http://example.com:0/"
+PASS URL: Setting <http://example.net:8080>.host = 'example.com:' Port number is unchanged if not specified 
+PASS <a>: Setting <http://example.net:8080>.host = 'example.com:' Port number is unchanged if not specified 
+PASS <area>: 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 
 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 

Modified: trunk/Source/WebCore/ChangeLog (264515 => 264516)


--- trunk/Source/WebCore/ChangeLog	2020-07-17 16:10:34 UTC (rev 264515)
+++ trunk/Source/WebCore/ChangeLog	2020-07-17 16:38:05 UTC (rev 264516)
@@ -1,3 +1,23 @@
+2020-07-17  Rob Buis  <[email protected]>
+
+        Changing URL.host should not override port
+        https://bugs.webkit.org/show_bug.cgi?id=151613
+
+        Reviewed by Alex Christensen.
+
+        When setting host, empty/incorrect port strings
+        should not change the existing port [1, 2].
+
+        Behavior matches Chrome and Firefox.
+
+        [1] https://url.spec.whatwg.org/#host-state Step 2.4
+        [2] https://url.spec.whatwg.org/#port-state Step 2.2
+
+        Test: imported/w3c/web-platform-tests/url/url-setters.html
+
+        * html/URLDecomposition.cpp:
+        (WebCore::URLDecomposition::setHost):
+
 2020-07-17  Truitt Savell  <[email protected]>
 
         Unreviewed, reverting r264477.

Modified: trunk/Source/WebCore/html/URLDecomposition.cpp (264515 => 264516)


--- trunk/Source/WebCore/html/URLDecomposition.cpp	2020-07-17 16:10:34 UTC (rev 264515)
+++ trunk/Source/WebCore/html/URLDecomposition.cpp	2020-07-17 16:38:05 UTC (rev 264516)
@@ -116,11 +116,7 @@
             return;
         unsigned portLength = countASCIIDigits(value.substring(separator + 1));
         if (!portLength) {
-            // http://dev.w3.org/html5/spec/infrastructure.html#url-decomposition-idl-attributes
-            // specifically goes against RFC 3986 (p3.2) and
-            // requires setting the port to "0" if it is set to empty string.
-            // FIXME: This seems like something that has since been changed and this rule and code may be obsolete.
-            fullURL.setHostAndPort(makeString(value.substring(0, separator + 1), '0'));
+            fullURL.setHost(value.substring(0, separator));
         } else {
             auto portNumber = parseUInt16(value.substring(separator + 1, portLength));
             if (portNumber && WTF::isDefaultPortForProtocol(*portNumber, fullURL.protocol()))
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to