Changeset 279680 in webkit


Ignore:
Timestamp:
Jul 7, 2021, 3:45:11 PM (3 years ago)
Author:
achristensen@apple.com
Message:

URL host setter should pass host to URLParser instead of trying to encode it itself
https://bugs.webkit.org/show_bug.cgi?id=227749

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/WTF:

For non-special schemes, the host is percent-encoded instead of punycode-encoded.
Allowing the URL parser to handle all input directly does the right thing for non-special schemes.

  • wtf/URL.cpp:

(WTF::URL::setHost):
(WTF::URL::setHostAndPort):

Location:
trunk
Files:
6 edited

Legend:

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

    r279669 r279680  
     12021-07-07  Alex Christensen  <achristensen@webkit.org>
     2
     3        URL host setter should pass host to URLParser instead of trying to encode it itself
     4        https://bugs.webkit.org/show_bug.cgi?id=227749
     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  Chris Dumez  <cdumez@apple.com>
    213
  • trunk/LayoutTests/imported/w3c/web-platform-tests/url/url-setters-a-area.window-expected.txt

    r279666 r279680  
    133133PASS <a>: Setting <sc://x/>.host = '@'
    134134PASS <area>: Setting <sc://x/>.host = '@'
    135 FAIL <a>: Setting <sc://x/>.host = 'ß' assert_equals: expected "sc://%C3%9F/" but got "sc://xn--zca/"
    136 FAIL <area>: Setting <sc://x/>.host = 'ß' assert_equals: expected "sc://%C3%9F/" but got "sc://xn--zca/"
     135PASS <a>: Setting <sc://x/>.host = 'ß'
     136PASS <area>: Setting <sc://x/>.host = 'ß'
    137137PASS <a>: Setting <https://x/>.host = 'ß' IDNA Nontransitional_Processing
    138138PASS <area>: Setting <https://x/>.host = 'ß' IDNA Nontransitional_Processing
  • trunk/LayoutTests/imported/w3c/web-platform-tests/url/url-setters.any-expected.txt

    r279666 r279680  
    6767PASS URL: Setting <sc://x/>.host = '?'
    6868PASS URL: Setting <sc://x/>.host = '@'
    69 FAIL URL: Setting <sc://x/>.host = 'ß' assert_equals: expected "sc://%C3%9F/" but got "sc://xn--zca/"
     69PASS URL: Setting <sc://x/>.host = 'ß'
    7070PASS URL: Setting <https://x/>.host = 'ß' IDNA Nontransitional_Processing
    7171PASS URL: Setting <mailto:me@example.net>.host = 'example.com' Cannot-be-a-base means no host
  • trunk/LayoutTests/imported/w3c/web-platform-tests/url/url-setters.any.worker-expected.txt

    r279666 r279680  
    6767PASS URL: Setting <sc://x/>.host = '?'
    6868PASS URL: Setting <sc://x/>.host = '@'
    69 FAIL URL: Setting <sc://x/>.host = 'ß' assert_equals: expected "sc://%C3%9F/" but got "sc://xn--zca/"
     69PASS URL: Setting <sc://x/>.host = 'ß'
    7070PASS URL: Setting <https://x/>.host = 'ß' IDNA Nontransitional_Processing
    7171PASS URL: Setting <mailto:me@example.net>.host = 'example.com' Cannot-be-a-base means no host
  • trunk/Source/WTF/ChangeLog

    r279662 r279680  
     12021-07-07  Alex Christensen  <achristensen@webkit.org>
     2
     3        URL host setter should pass host to URLParser instead of trying to encode it itself
     4        https://bugs.webkit.org/show_bug.cgi?id=227749
     5
     6        Reviewed by Chris Dumez.
     7
     8        For non-special schemes, the host is percent-encoded instead of punycode-encoded.
     9        Allowing the URL parser to handle all input directly does the right thing for non-special schemes.
     10
     11        * wtf/URL.cpp:
     12        (WTF::URL::setHost):
     13        (WTF::URL::setHostAndPort):
     14
    1152021-07-07  Alex Christensen  <achristensen@webkit.org>
    216
  • trunk/Source/WTF/wtf/URL.cpp

    r279662 r279680  
    461461
    462462    Vector<UChar, 512> encodedHostName;
    463     if (!appendEncodedHostname(encodedHostName, newHost))
     463    if (hasSpecialScheme() && !appendEncodedHostname(encodedHostName, newHost))
    464464        return;
    465465
     
    468468        StringView(m_string).left(hostStart()),
    469469        slashSlashNeeded ? "//" : "",
    470         StringView(encodedHostName.data(), encodedHostName.size()),
     470        hasSpecialScheme() ? StringView(encodedHostName.data(), encodedHostName.size()) : newHost,
    471471        StringView(m_string).substring(m_hostEnd)
    472472    ));
     
    514514
    515515    Vector<UChar, 512> encodedHostName;
    516     if (!appendEncodedHostname(encodedHostName, hostName))
     516    if (hasSpecialScheme() && !appendEncodedHostname(encodedHostName, hostName))
    517517        return;
    518518
     
    521521        StringView(m_string).left(hostStart()),
    522522        slashSlashNeeded ? "//" : "",
    523         StringView(encodedHostName.data(), encodedHostName.size()),
     523        hasSpecialScheme() ? StringView(encodedHostName.data(), encodedHostName.size()) : hostName,
    524524        portString.isEmpty() ? "" : ":",
    525525        portString,
Note: See TracChangeset for help on using the changeset viewer.