Changeset 264516 in webkit


Ignore:
Timestamp:
Jul 17, 2020, 9:38:05 AM (5 years ago)
Author:
commit-queue@webkit.org
Message:

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

Patch by Rob Buis <rbuis@igalia.com> 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:
Location:
trunk
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r264505 r264516  
     12020-07-17  Rob Buis  <rbuis@igalia.com>
     2
     3        Changing URL.host should not override port
     4        https://bugs.webkit.org/show_bug.cgi?id=151613
     5
     6        Reviewed by Alex Christensen.
     7
     8        Adjust tests to expect the new behavior.
     9
     10        * fast/dom/DOMURL/set-href-attribute-host-expected.txt:
     11        * fast/dom/DOMURL/set-href-attribute-host.html:
     12        * fast/dom/HTMLAnchorElement/set-href-attribute-host-expected.txt:
     13        * fast/dom/HTMLAnchorElement/set-href-attribute-host.html:
     14
    1152020-07-17  Lauro Moura  <lmoura@igalia.com>
    216
  • trunk/LayoutTests/fast/dom/DOMURL/set-href-attribute-host-expected.txt

    r261212 r264516  
    1515PASS a.href is 'https://www.otherdomain.com:44/path/'
    1616Leading space in port number
    17 PASS a.href is 'https://www.otherdomain.com:0/path/'
     17PASS a.href is 'https://www.otherdomain.com:8080/path/'
    1818Colon without port number
    19 PASS a.href is 'https://www.otherdomain.com:0/path/'
     19PASS a.href is 'https://www.otherdomain.com:8080/path/'
    2020Set host to null
    2121PASS a.href is 'https://null:8080/path/'
  • trunk/LayoutTests/fast/dom/DOMURL/set-href-attribute-host.html

    r261212 r264516  
    4747a.href = "https://www.mydomain.com:8080/path/";
    4848a.host = "www.otherdomain.com: 443";
    49 shouldBe("a.href", "'https://www.otherdomain.com:0/path/'");
     49shouldBe("a.href", "'https://www.otherdomain.com:8080/path/'");
    5050
    5151// Firefox 3.5.2 removed the port, clearly against the spec .
     
    5353a.href = "https://www.mydomain.com:8080/path/";
    5454a.host = "www.otherdomain.com:";
    55 shouldBe("a.href", "'https://www.otherdomain.com:0/path/'");
     55shouldBe("a.href", "'https://www.otherdomain.com:8080/path/'");
    5656
    5757debug("Set host to null");
  • trunk/LayoutTests/fast/dom/HTMLAnchorElement/set-href-attribute-host-expected.txt

    r261212 r264516  
    1515PASS a.href is 'https://www.otherdomain.com:44/path/'
    1616Leading space in port number
    17 PASS a.href is 'https://www.otherdomain.com:0/path/'
     17PASS a.href is 'https://www.otherdomain.com:8080/path/'
    1818Colon without port number
    19 PASS a.href is 'https://www.otherdomain.com:0/path/'
     19PASS a.href is 'https://www.otherdomain.com:8080/path/'
    2020Set host to null
    2121PASS a.href is 'https://null:8080/path/'
  • trunk/LayoutTests/fast/dom/HTMLAnchorElement/set-href-attribute-host.html

    r261212 r264516  
    4545a.href = "https://www.mydomain.com:8080/path/";
    4646a.host = "www.otherdomain.com: 443";
    47 shouldBe("a.href", "'https://www.otherdomain.com:0/path/'");
     47shouldBe("a.href", "'https://www.otherdomain.com:8080/path/'");
    4848
    4949// Firefox 3.5.2 removed the port, clearly against the spec .
     
    5151a.href = "https://www.mydomain.com:8080/path/";
    5252a.host = "www.otherdomain.com:";
    53 shouldBe("a.href", "'https://www.otherdomain.com:0/path/'");
     53shouldBe("a.href", "'https://www.otherdomain.com:8080/path/'");
    5454
    5555debug("Set host to null");
  • trunk/LayoutTests/imported/w3c/ChangeLog

    r264478 r264516  
     12020-07-17  Rob Buis  <rbuis@igalia.com>
     2
     3        Changing URL.host should not override port
     4        https://bugs.webkit.org/show_bug.cgi?id=151613
     5
     6        Reviewed by Alex Christensen.
     7
     8        Update improved test result.
     9
     10        * web-platform-tests/url/url-setters-expected.txt:
     11
    1122020-07-16  Chris Dumez  <cdumez@apple.com>
    213
  • trunk/LayoutTests/imported/w3c/web-platform-tests/url/url-setters-expected.txt

    r264282 r264516  
    217217PASS <a>: Setting <http://example.net:8080>.host = 'example.com' Port number is unchanged if not specified in the new value
    218218PASS <area>: Setting <http://example.net:8080>.host = 'example.com' Port number is unchanged if not specified in the new value
    219 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/"
    220 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/"
    221 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/"
     219PASS URL: Setting <http://example.net:8080>.host = 'example.com:' Port number is unchanged if not specified
     220PASS <a>: Setting <http://example.net:8080>.host = 'example.com:' Port number is unchanged if not specified
     221PASS <area>: Setting <http://example.net:8080>.host = 'example.com:' Port number is unchanged if not specified
    222222PASS URL: Setting <http://example.net>.host = '' The empty host is not valid for special schemes
    223223PASS <a>: Setting <http://example.net>.host = '' The empty host is not valid for special schemes
  • trunk/Source/WebCore/ChangeLog

    r264515 r264516  
     12020-07-17  Rob Buis  <rbuis@igalia.com>
     2
     3        Changing URL.host should not override port
     4        https://bugs.webkit.org/show_bug.cgi?id=151613
     5
     6        Reviewed by Alex Christensen.
     7
     8        When setting host, empty/incorrect port strings
     9        should not change the existing port [1, 2].
     10
     11        Behavior matches Chrome and Firefox.
     12
     13        [1] https://url.spec.whatwg.org/#host-state Step 2.4
     14        [2] https://url.spec.whatwg.org/#port-state Step 2.2
     15
     16        Test: imported/w3c/web-platform-tests/url/url-setters.html
     17
     18        * html/URLDecomposition.cpp:
     19        (WebCore::URLDecomposition::setHost):
     20
    1212020-07-17  Truitt Savell  <tsavell@apple.com>
    222
  • trunk/Source/WebCore/html/URLDecomposition.cpp

    r264282 r264516  
    117117        unsigned portLength = countASCIIDigits(value.substring(separator + 1));
    118118        if (!portLength) {
    119             // http://dev.w3.org/html5/spec/infrastructure.html#url-decomposition-idl-attributes
    120             // specifically goes against RFC 3986 (p3.2) and
    121             // requires setting the port to "0" if it is set to empty string.
    122             // FIXME: This seems like something that has since been changed and this rule and code may be obsolete.
    123             fullURL.setHostAndPort(makeString(value.substring(0, separator + 1), '0'));
     119            fullURL.setHost(value.substring(0, separator));
    124120        } else {
    125121            auto portNumber = parseUInt16(value.substring(separator + 1, portLength));
Note: See TracChangeset for help on using the changeset viewer.