Changeset 254672 in webkit


Ignore:
Timestamp:
Jan 16, 2020 4:13:17 AM (4 years ago)
Author:
commit-queue@webkit.org
Message:

Fetch: URL parser not always using UTF-8
https://bugs.webkit.org/show_bug.cgi?id=178008

Patch by Rob Buis <rbuis@igalia.com> on 2020-01-16
Reviewed by Youenn Fablet.

LayoutTests/imported/w3c:

Update improved test result.

  • web-platform-tests/fetch/api/request/url-encoding-expected.txt:

Source/WebCore:

Make sure fetch requests run the URL parser with a UTF-8 decoder.

Test: web-platform-tests/fetch/api/request/url-encoding.html

  • Modules/fetch/FetchRequest.cpp:

(WebCore::FetchRequest::initializeWith):

  • dom/Document.cpp:

(WebCore::Document::completeURL const):

  • dom/Document.h:
  • dom/ScriptExecutionContext.h:
  • workers/WorkerGlobalScope.cpp:

(WebCore::WorkerGlobalScope::completeURL const):

  • workers/WorkerGlobalScope.h:
  • worklets/WorkletGlobalScope.cpp:

(WebCore::WorkletGlobalScope::completeURL const):

  • worklets/WorkletGlobalScope.h:
Location:
trunk
Files:
11 edited

Legend:

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

    r254669 r254672  
     12020-01-16  Rob Buis  <rbuis@igalia.com>
     2
     3        Fetch: URL parser not always using UTF-8
     4        https://bugs.webkit.org/show_bug.cgi?id=178008
     5
     6        Reviewed by Youenn Fablet.
     7
     8        Update improved test result.
     9
     10        * web-platform-tests/fetch/api/request/url-encoding-expected.txt:
     11
    1122020-01-16  Cathie Chen  <cathiechen@igalia.com>
    213
  • trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/request/url-encoding-expected.txt

    r223441 r254672  
    11
    2 FAIL URL encoding and Request assert_equals: expected "http://localhost:8800/fetch/api/request/url-encoding.html?%C3%9F" but got "http://localhost:8800/fetch/api/request/url-encoding.html?%DF"
    3 FAIL URL encoding and fetch() assert_equals: expected "http://localhost:8800/fetch/api/request/url-encoding.html?%C3%9F" but got "http://localhost:8800/fetch/api/request/url-encoding.html?%DF"
     2PASS URL encoding and Request
     3PASS URL encoding and fetch()
    44
  • trunk/Source/WebCore/ChangeLog

    r254670 r254672  
     12020-01-16  Rob Buis  <rbuis@igalia.com>
     2
     3        Fetch: URL parser not always using UTF-8
     4        https://bugs.webkit.org/show_bug.cgi?id=178008
     5
     6        Reviewed by Youenn Fablet.
     7
     8        Make sure fetch requests run the URL parser with a UTF-8 decoder.
     9
     10        Test: web-platform-tests/fetch/api/request/url-encoding.html
     11
     12        * Modules/fetch/FetchRequest.cpp:
     13        (WebCore::FetchRequest::initializeWith):
     14        * dom/Document.cpp:
     15        (WebCore::Document::completeURL const):
     16        * dom/Document.h:
     17        * dom/ScriptExecutionContext.h:
     18        * workers/WorkerGlobalScope.cpp:
     19        (WebCore::WorkerGlobalScope::completeURL const):
     20        * workers/WorkerGlobalScope.h:
     21        * worklets/WorkletGlobalScope.cpp:
     22        (WebCore::WorkletGlobalScope::completeURL const):
     23        * worklets/WorkletGlobalScope.h:
     24
    1252020-01-16  Alicia Boya García  <aboya@igalia.com>
    226
  • trunk/Source/WebCore/Modules/fetch/FetchRequest.cpp

    r252349 r254672  
    162162    ASSERT(scriptExecutionContext());
    163163    // FIXME: Tighten the URL parsing algorithm according https://url.spec.whatwg.org/#concept-url-parser.
    164     URL requestURL = scriptExecutionContext()->completeURL(url);
     164    URL requestURL = scriptExecutionContext()->completeURL(url, ScriptExecutionContext::ForceUTF8::Yes);
    165165    if (!requestURL.isValid() || !requestURL.user().isEmpty() || !requestURL.pass().isEmpty())
    166166        return Exception { TypeError, "URL is not valid or contains user credentials."_s };
  • trunk/Source/WebCore/dom/Document.cpp

    r254652 r254672  
    52065206}
    52075207
    5208 URL Document::completeURL(const String& url, const URL& baseURLOverride) const
     5208URL Document::completeURL(const String& url, const URL& baseURLOverride, ForceUTF8 forceUTF8) const
    52095209{
    52105210    // Always return a null URL when passed a null string.
     
    52145214        return URL();
    52155215    const URL& baseURL = ((baseURLOverride.isEmpty() || baseURLOverride == WTF::blankURL()) && parentDocument()) ? parentDocument()->baseURL() : baseURLOverride;
    5216     if (!m_decoder)
     5216    if (!m_decoder || forceUTF8 == ForceUTF8::Yes)
    52175217        return URL(baseURL, url);
    52185218    return URL(baseURL, url, m_decoder->encodingForURLParsing());
    52195219}
    52205220
    5221 URL Document::completeURL(const String& url) const
    5222 {
    5223     return completeURL(url, m_baseURL);
     5221URL Document::completeURL(const String& url, ForceUTF8 forceUTF8) const
     5222{
     5223    return completeURL(url, m_baseURL, forceUTF8);
    52245224}
    52255225
  • trunk/Source/WebCore/dom/Document.h

    r254652 r254672  
    688688    void processBaseElement();
    689689
    690     WEBCORE_EXPORT URL completeURL(const String&) const final;
    691     URL completeURL(const String&, const URL& baseURLOverride) const;
     690    WEBCORE_EXPORT URL completeURL(const String&, ForceUTF8 = ForceUTF8::No) const final;
     691    URL completeURL(const String&, const URL& baseURLOverride, ForceUTF8 = ForceUTF8::No) const;
    692692
    693693    String userAgent(const URL&) const final;
  • trunk/Source/WebCore/dom/ScriptExecutionContext.h

    r254182 r254672  
    9595
    9696    virtual const URL& url() const = 0;
    97     virtual URL completeURL(const String& url) const = 0;
     97    enum class ForceUTF8 { No, Yes };
     98    virtual URL completeURL(const String& url, ForceUTF8 = ForceUTF8::No) const = 0;
    9899
    99100    virtual String userAgent(const URL&) const = 0;
  • trunk/Source/WebCore/workers/WorkerGlobalScope.cpp

    r253091 r254672  
    168168}
    169169
    170 URL WorkerGlobalScope::completeURL(const String& url) const
     170URL WorkerGlobalScope::completeURL(const String& url, ForceUTF8) const
    171171{
    172172    // Always return a null URL when passed a null string.
  • trunk/Source/WebCore/workers/WorkerGlobalScope.h

    r254182 r254672  
    161161
    162162    ScriptExecutionContext* scriptExecutionContext() const final { return const_cast<WorkerGlobalScope*>(this); }
    163     URL completeURL(const String&) const final;
     163    URL completeURL(const String&, ForceUTF8 = ForceUTF8::No) const final;
    164164    String userAgent(const URL&) const final;
    165165    void disableEval(const String& errorMessage) final;
  • trunk/Source/WebCore/worklets/WorkletGlobalScope.cpp

    r254182 r254672  
    132132}
    133133
    134 URL WorkletGlobalScope::completeURL(const String& url) const
     134URL WorkletGlobalScope::completeURL(const String& url, ForceUTF8) const
    135135{
    136136    if (url.isNull())
  • trunk/Source/WebCore/worklets/WorkletGlobalScope.h

    r254182 r254672  
    121121    bool unwrapCryptoKey(const Vector<uint8_t>&, Vector<uint8_t>&) final { RELEASE_ASSERT_NOT_REACHED(); return false; }
    122122#endif
    123     URL completeURL(const String&) const final;
     123    URL completeURL(const String&, ForceUTF8 = ForceUTF8::No) const final;
    124124    String userAgent(const URL&) const final;
    125125    void disableEval(const String&) final;
Note: See TracChangeset for help on using the changeset viewer.