Changeset 279666 in webkit


Ignore:
Timestamp:
Jul 7, 2021 1:59:59 PM (3 years ago)
Author:
achristensen@apple.com
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):

Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/imported/w3c/ChangeLog

    r279662 r279666  
     12021-07-07  Alex Christensen  <achristensen@webkit.org>
     2
     3        Allow setting empty hosts of URLs with non-special schemes
     4        https://bugs.webkit.org/show_bug.cgi?id=227752
     5
     6        Reviewed by Chris Dumez.
     7
     8        * web-platform-tests/url/url-setters-a-area.window-expected.txt:
     9        * web-platform-tests/url/url-setters.any-expected.txt:
     10        * web-platform-tests/url/url-setters.any.worker-expected.txt:
     11
    1122021-07-07  Alex Christensen  <achristensen@webkit.org>
    213
  • trunk/LayoutTests/imported/w3c/web-platform-tests/url/url-setters-a-area.window-expected.txt

    r279662 r279666  
    149149PASS <a>: Setting <http://example.net>.host = '' The empty host is not valid for special schemes
    150150PASS <area>: Setting <http://example.net>.host = '' The empty host is not valid for special schemes
    151 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"
    152 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"
     151PASS <a>: Setting <view-source+http://example.net/foo>.host = '' The empty host is OK for non-special schemes
     152PASS <area>: Setting <view-source+http://example.net/foo>.host = '' The empty host is OK for non-special schemes
    153153PASS <a>: Setting <a:/foo>.host = 'example.net' Path-only URLs can gain a host
    154154PASS <area>: Setting <a:/foo>.host = 'example.net' Path-only URLs can gain a host
     
    233233PASS <a>: Setting <sc://x/>.hostname = '#'
    234234PASS <area>: Setting <sc://x/>.hostname = '#'
    235 FAIL <a>: Setting <sc://x/>.hostname = '/' assert_equals: expected "sc:///" but got "sc://x/"
    236 FAIL <area>: Setting <sc://x/>.hostname = '/' assert_equals: expected "sc:///" but got "sc://x/"
     235PASS <a>: Setting <sc://x/>.hostname = '/'
     236PASS <area>: Setting <sc://x/>.hostname = '/'
    237237PASS <a>: Setting <sc://x/>.hostname = '?'
    238238PASS <area>: Setting <sc://x/>.hostname = '?'
     
    247247PASS <a>: Setting <http://example.net>.hostname = '' The empty host is not valid for special schemes
    248248PASS <area>: Setting <http://example.net>.hostname = '' The empty host is not valid for special schemes
    249 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"
    250 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"
     249PASS <a>: Setting <view-source+http://example.net/foo>.hostname = '' The empty host is OK for non-special schemes
     250PASS <area>: Setting <view-source+http://example.net/foo>.hostname = '' The empty host is OK for non-special schemes
    251251PASS <a>: Setting <a:/foo>.hostname = 'example.net' Path-only URLs can gain a host
    252252PASS <area>: Setting <a:/foo>.hostname = 'example.net' Path-only URLs can gain a host
     
    291291PASS <a>: Setting <non-spec:/.//p>.hostname = 'h' Drop /. from path
    292292PASS <area>: Setting <non-spec:/.//p>.hostname = 'h' Drop /. from path
    293 FAIL <a>: Setting <non-spec:/.//p>.hostname = '' assert_equals: expected "non-spec:////p" but got "non-spec:/.//p"
    294 FAIL <area>: Setting <non-spec:/.//p>.hostname = '' assert_equals: expected "non-spec:////p" but got "non-spec:/.//p"
     293PASS <a>: Setting <non-spec:/.//p>.hostname = ''
     294PASS <area>: Setting <non-spec:/.//p>.hostname = ''
    295295FAIL <a>: Setting <http://example.com/>.hostname = '///bad.com' Leading / is not stripped assert_equals: expected "http://example.com/" but got "http://bad.com/"
    296296FAIL <area>: Setting <http://example.com/>.hostname = '///bad.com' Leading / is not stripped assert_equals: expected "http://example.com/" but got "http://bad.com/"
  • trunk/LayoutTests/imported/w3c/web-platform-tests/url/url-setters.any-expected.txt

    r279662 r279666  
    7575PASS URL: Setting <http://example.net:8080>.host = 'example.com:' Port number is unchanged if not specified
    7676PASS URL: Setting <http://example.net>.host = '' The empty host is not valid for special schemes
    77 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"
     77PASS URL: Setting <view-source+http://example.net/foo>.host = '' The empty host is OK for non-special schemes
    7878PASS URL: Setting <a:/foo>.host = 'example.net' Path-only URLs can gain a host
    7979PASS URL: Setting <http://example.net>.host = '0x7F000001:8080' IPv4 address syntax is normalized
     
    117117PASS URL: Setting <sc://x/>.hostname = ' '
    118118PASS URL: Setting <sc://x/>.hostname = '#'
    119 FAIL URL: Setting <sc://x/>.hostname = '/' assert_equals: expected "sc:///" but got "sc://x/"
     119PASS URL: Setting <sc://x/>.hostname = '/'
    120120PASS URL: Setting <sc://x/>.hostname = '?'
    121121PASS URL: Setting <sc://x/>.hostname = '@'
     
    124124PASS URL: Setting <http://example.net:8080>.hostname = 'example.com'
    125125PASS URL: Setting <http://example.net>.hostname = '' The empty host is not valid for special schemes
    126 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"
     126PASS URL: Setting <view-source+http://example.net/foo>.hostname = '' The empty host is OK for non-special schemes
    127127PASS URL: Setting <a:/foo>.hostname = 'example.net' Path-only URLs can gain a host
    128128PASS URL: Setting <http://example.net:8080>.hostname = '0x7F000001' IPv4 address syntax is normalized
     
    146146PASS URL: Setting <sc://test:12/>.hostname = ''
    147147PASS URL: Setting <non-spec:/.//p>.hostname = 'h' Drop /. from path
    148 FAIL URL: Setting <non-spec:/.//p>.hostname = '' assert_equals: expected "non-spec:////p" but got "non-spec:/.//p"
     148PASS URL: Setting <non-spec:/.//p>.hostname = ''
    149149FAIL URL: Setting <http://example.com/>.hostname = '///bad.com' Leading / is not stripped assert_equals: expected "http://example.com/" but got "http://bad.com/"
    150150FAIL URL: Setting <sc://example.com/>.hostname = '///bad.com' Leading / is not stripped assert_equals: expected "sc:///" but got "sc://bad.com/"
  • trunk/LayoutTests/imported/w3c/web-platform-tests/url/url-setters.any.worker-expected.txt

    r279662 r279666  
    7575PASS URL: Setting <http://example.net:8080>.host = 'example.com:' Port number is unchanged if not specified
    7676PASS URL: Setting <http://example.net>.host = '' The empty host is not valid for special schemes
    77 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"
     77PASS URL: Setting <view-source+http://example.net/foo>.host = '' The empty host is OK for non-special schemes
    7878PASS URL: Setting <a:/foo>.host = 'example.net' Path-only URLs can gain a host
    7979PASS URL: Setting <http://example.net>.host = '0x7F000001:8080' IPv4 address syntax is normalized
     
    117117PASS URL: Setting <sc://x/>.hostname = ' '
    118118PASS URL: Setting <sc://x/>.hostname = '#'
    119 FAIL URL: Setting <sc://x/>.hostname = '/' assert_equals: expected "sc:///" but got "sc://x/"
     119PASS URL: Setting <sc://x/>.hostname = '/'
    120120PASS URL: Setting <sc://x/>.hostname = '?'
    121121PASS URL: Setting <sc://x/>.hostname = '@'
     
    124124PASS URL: Setting <http://example.net:8080>.hostname = 'example.com'
    125125PASS URL: Setting <http://example.net>.hostname = '' The empty host is not valid for special schemes
    126 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"
     126PASS URL: Setting <view-source+http://example.net/foo>.hostname = '' The empty host is OK for non-special schemes
    127127PASS URL: Setting <a:/foo>.hostname = 'example.net' Path-only URLs can gain a host
    128128PASS URL: Setting <http://example.net:8080>.hostname = '0x7F000001' IPv4 address syntax is normalized
     
    146146PASS URL: Setting <sc://test:12/>.hostname = ''
    147147PASS URL: Setting <non-spec:/.//p>.hostname = 'h' Drop /. from path
    148 FAIL URL: Setting <non-spec:/.//p>.hostname = '' assert_equals: expected "non-spec:////p" but got "non-spec:/.//p"
     148PASS URL: Setting <non-spec:/.//p>.hostname = ''
    149149FAIL URL: Setting <http://example.com/>.hostname = '///bad.com' Leading / is not stripped assert_equals: expected "http://example.com/" but got "http://bad.com/"
    150150FAIL URL: Setting <sc://example.com/>.hostname = '///bad.com' Leading / is not stripped assert_equals: expected "sc:///" but got "sc://bad.com/"
  • trunk/Source/WebCore/ChangeLog

    r279661 r279666  
     12021-07-07  Alex Christensen  <achristensen@webkit.org>
     2
     3        Allow setting empty hosts of URLs with non-special schemes
     4        https://bugs.webkit.org/show_bug.cgi?id=227752
     5
     6        Reviewed by Chris Dumez.
     7
     8        asdf:/// is fine.
     9        http:/// is not fine.
     10
     11        * html/URLDecomposition.cpp:
     12        (WebCore::URLDecomposition::setHost):
     13        (WebCore::URLDecomposition::setHostname):
     14        (WebCore::URLDecomposition::hash const):
     15
    1162021-07-07  Ryosuke Niwa  <rniwa@webkit.org>
    217
  • trunk/Source/WebCore/html/URLDecomposition.cpp

    r278253 r279666  
    9898{
    9999    auto fullURL = this->fullURL();
    100     if (value.isEmpty() && !fullURL.protocolIs("file"))
     100    if (value.isEmpty() && !fullURL.protocolIs("file") && fullURL.hasSpecialScheme())
    101101        return;
    102102
     
    151151    auto fullURL = this->fullURL();
    152152    auto host = removeAllLeadingSolidusCharacters(value);
    153     if (host.isEmpty() && !fullURL.protocolIs("file"))
     153    if (host.isEmpty() && !fullURL.protocolIs("file") && fullURL.hasSpecialScheme())
    154154        return;
    155155    if (fullURL.cannotBeABaseURL() || !fullURL.canSetHostOrPort())
     
    230230String URLDecomposition::hash() const
    231231{
    232     // FIXME: Why convert this string to an atom here instead of just a string? Intentionally to save memory? An error?
    233     auto fullURL = this->fullURL();
    234     return fullURL.fragmentIdentifier().isEmpty() ? emptyAtom() : fullURL.fragmentIdentifierWithLeadingNumberSign().toAtomString();
     232    auto fullURL = this->fullURL();
     233    return fullURL.fragmentIdentifier().isEmpty() ? emptyString() : fullURL.fragmentIdentifierWithLeadingNumberSign().toString();
    235234}
    236235
Note: See TracChangeset for help on using the changeset viewer.