Changeset 252998 in webkit


Ignore:
Timestamp:
Dec 2, 2019 10:56:49 AM (4 years ago)
Author:
commit-queue@webkit.org
Message:

Incorrect association of the URL object with the value port
https://bugs.webkit.org/show_bug.cgi?id=204414

Patch by Alex Christensen <achristensen@webkit.org> on 2019-12-02
Reviewed by Sam Weinig.

LayoutTests/imported/w3c:

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

Source/WebCore:

Setting a port should clear the port if it's not a numerical value.
We now match the behavior of Chrome, Firefox, and the URL specification.
Covered by a newly passing WPT!

  • html/URLUtils.h:

(WebCore::URLUtils<T>::setPort):

LayoutTests:

  • fast/dom/DOMURL/set-href-attribute-port-expected.txt:
  • fast/dom/DOMURL/set-href-attribute-port.html:
  • fast/dom/HTMLAnchorElement/set-href-attribute-port-expected.txt:
  • fast/dom/HTMLAnchorElement/set-href-attribute-port.html:
Location:
trunk
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r252990 r252998  
     12019-12-02  Alex Christensen  <achristensen@webkit.org>
     2
     3        Incorrect association of the URL object with the value port
     4        https://bugs.webkit.org/show_bug.cgi?id=204414
     5
     6        Reviewed by Sam Weinig.
     7
     8        * fast/dom/DOMURL/set-href-attribute-port-expected.txt:
     9        * fast/dom/DOMURL/set-href-attribute-port.html:
     10        * fast/dom/HTMLAnchorElement/set-href-attribute-port-expected.txt:
     11        * fast/dom/HTMLAnchorElement/set-href-attribute-port.html:
     12
    1132019-12-02  Truitt Savell  <tsavell@apple.com>
    214
  • trunk/LayoutTests/fast/dom/DOMURL/set-href-attribute-port-expected.txt

    r163208 r252998  
    1313PASS a.href is 'https://www.mydomain.com:4/path/testurl.html?key=value'
    1414Set port to null
    15 PASS a.href is 'https://www.mydomain.com:0/path/testurl.html?key=value'
     15PASS a.href is 'https://www.mydomain.com/path/testurl.html?key=value'
    1616Set port to empty string
    17 PASS a.href is 'https://www.mydomain.com:0/path/testurl.html?key=value'
     17PASS a.href is 'https://www.mydomain.com/path/testurl.html?key=value'
    1818Set port to undefined
    19 PASS a.href is 'https://www.mydomain.com:0/path/testurl.html?key=value'
     19PASS a.href is 'https://www.mydomain.com/path/testurl.html?key=value'
    2020Set port to URL with foo: protocol
    2121PASS a.href is 'foo://bar:50/'
  • trunk/LayoutTests/fast/dom/DOMURL/set-href-attribute-port.html

    r163208 r252998  
    3737a.href = "https://www.mydomain.com:8080/path/testurl.html?key=value";
    3838a.port = null;
    39 shouldBe("a.href", "'https://www.mydomain.com:0/path/testurl.html?key=value'");
     39shouldBe("a.href", "'https://www.mydomain.com/path/testurl.html?key=value'");
    4040
    4141// Firefox 3.5.2 does not accept the port if it is null.
     
    4343a.href = "https://www.mydomain.com:8080/path/testurl.html?key=value";
    4444a.port = "";
    45 shouldBe("a.href", "'https://www.mydomain.com:0/path/testurl.html?key=value'");
     45shouldBe("a.href", "'https://www.mydomain.com/path/testurl.html?key=value'");
    4646
    4747debug("Set port to undefined");
    4848a.href = "https://www.mydomain.com:8080/path/testurl.html?key=value";
    4949a.port = undefined;
    50 shouldBe("a.href", "'https://www.mydomain.com:0/path/testurl.html?key=value'");
     50shouldBe("a.href", "'https://www.mydomain.com/path/testurl.html?key=value'");
    5151
    5252// Firefox 3.5.2 does not allow setting the port on a URL with protocol foo: .
  • trunk/LayoutTests/fast/dom/HTMLAnchorElement/set-href-attribute-port-expected.txt

    r50784 r252998  
    1313PASS a.href is 'https://www.mydomain.com:4/path/testurl.html?key=value'
    1414Set port to null
    15 PASS a.href is 'https://www.mydomain.com:0/path/testurl.html?key=value'
     15PASS a.href is 'https://www.mydomain.com/path/testurl.html?key=value'
    1616Set port to empty string
    17 PASS a.href is 'https://www.mydomain.com:0/path/testurl.html?key=value'
     17PASS a.href is 'https://www.mydomain.com/path/testurl.html?key=value'
    1818Set port to undefined
    19 PASS a.href is 'https://www.mydomain.com:0/path/testurl.html?key=value'
     19PASS a.href is 'https://www.mydomain.com/path/testurl.html?key=value'
    2020Set port to URL with foo: protocol
    2121PASS a.href is 'foo://bar:50/'
  • trunk/LayoutTests/fast/dom/HTMLAnchorElement/set-href-attribute-port.html

    r217390 r252998  
    3535a.href = "https://www.mydomain.com:8080/path/testurl.html?key=value";
    3636a.port = null;
    37 shouldBe("a.href", "'https://www.mydomain.com:0/path/testurl.html?key=value'");
     37shouldBe("a.href", "'https://www.mydomain.com/path/testurl.html?key=value'");
    3838
    3939// Firefox 3.5.2 does not accept the port if it is null.
     
    4141a.href = "https://www.mydomain.com:8080/path/testurl.html?key=value";
    4242a.port = "";
    43 shouldBe("a.href", "'https://www.mydomain.com:0/path/testurl.html?key=value'");
     43shouldBe("a.href", "'https://www.mydomain.com/path/testurl.html?key=value'");
    4444
    4545debug("Set port to undefined");
    4646a.href = "https://www.mydomain.com:8080/path/testurl.html?key=value";
    4747a.port = undefined;
    48 shouldBe("a.href", "'https://www.mydomain.com:0/path/testurl.html?key=value'");
     48shouldBe("a.href", "'https://www.mydomain.com/path/testurl.html?key=value'");
    4949
    5050// Firefox 3.5.2 does not allow setting the port on a URL with protocol foo: .
  • trunk/LayoutTests/imported/w3c/ChangeLog

    r252983 r252998  
     12019-12-02  Alex Christensen  <achristensen@webkit.org>
     2
     3        Incorrect association of the URL object with the value port
     4        https://bugs.webkit.org/show_bug.cgi?id=204414
     5
     6        Reviewed by Sam Weinig.
     7
     8        * web-platform-tests/url/url-setters-expected.txt:
     9
    1102019-12-02  Simon Fraser  <simon.fraser@apple.com>
    211
  • trunk/LayoutTests/imported/w3c/web-platform-tests/url/url-setters-expected.txt

    r251422 r252998  
    424424PASS <a>: Setting <http://example.net>.port = '8080'
    425425PASS <area>: Setting <http://example.net>.port = '8080'
    426 FAIL URL: Setting <http://example.net:8080>.port = '' Port number is removed if empty is the new value assert_equals: expected "http://example.net/" but got "http://example.net:0/"
    427 FAIL <a>: Setting <http://example.net:8080>.port = '' Port number is removed if empty is the new value assert_equals: expected "http://example.net/" but got "http://example.net:0/"
    428 FAIL <area>: Setting <http://example.net:8080>.port = '' Port number is removed if empty is the new value assert_equals: expected "http://example.net/" but got "http://example.net:0/"
     426PASS URL: Setting <http://example.net:8080>.port = '' Port number is removed if empty is the new value
     427PASS <a>: Setting <http://example.net:8080>.port = '' Port number is removed if empty is the new value
     428PASS <area>: Setting <http://example.net:8080>.port = '' Port number is removed if empty is the new value
    429429PASS URL: Setting <http://example.net:8080>.port = '80' Default port number is removed
    430430PASS <a>: Setting <http://example.net:8080>.port = '80' Default port number is removed
  • trunk/Source/WebCore/ChangeLog

    r252992 r252998  
     12019-12-02  Alex Christensen  <achristensen@webkit.org>
     2
     3        Incorrect association of the URL object with the value port
     4        https://bugs.webkit.org/show_bug.cgi?id=204414
     5
     6        Reviewed by Sam Weinig.
     7
     8        Setting a port should clear the port if it's not a numerical value.
     9        We now match the behavior of Chrome, Firefox, and the URL specification.
     10        Covered by a newly passing WPT!
     11
     12        * html/URLUtils.h:
     13        (WebCore::URLUtils<T>::setPort):
     14
    1152019-11-30  Dean Jackson  <dino@apple.com>
    216
  • trunk/Source/WebCore/html/URLUtils.h

    r246490 r252998  
    233233        return;
    234234
    235     // http://dev.w3.org/html5/spec/infrastructure.html#url-decomposition-idl-attributes
    236     // specifically goes against RFC 3986 (p3.2) and
    237     // requires setting the port to "0" if it is set to empty string.
    238     // FIXME: http://url.spec.whatwg.org/ doesn't appear to require this; test what browsers do
    239     unsigned port = value.toUInt();
    240     if (WTF::isDefaultPortForProtocol(port, url.protocol()))
     235    bool success = true;
     236    unsigned port = value.toUInt(&success);
     237    if (!success || WTF::isDefaultPortForProtocol(port, url.protocol()))
    241238        url.removePort();
    242239    else
Note: See TracChangeset for help on using the changeset viewer.