Changeset 277087 in webkit


Ignore:
Timestamp:
May 6, 2021 7:52:13 AM (3 years ago)
Author:
Chris Dumez
Message:

imported/w3c/web-platform-tests/eventsource/format-utf-8.htm is failing on some platforms
https://bugs.webkit.org/show_bug.cgi?id=225416
<rdar://77529801>

Reviewed by Youenn Fablet.

Source/WebCore:

The HTML specification [1] states that EventSource streams should always be decoded as UTF-8.
However, we had logic in WebKit that was checking the charset of the response and aborting
when the charset is not UTF-8. It looks like we were lucky until now that we would fail to
determine the charset of the response and proceed anyway. However, due to underlying system
changes, in the context of this test, we are now properly detecting the response charset as
"windows-1252" and (incorrectly) aborting. To address the issue, I no longer abort the
connection if the charset is not "utf-8". We do still log a console warning but we proceed
decoding the stream as UTF-8 no matter the response's charset, as per the specification.

[1] https://html.spec.whatwg.org/multipage/server-sent-events.html#event-stream-interpretation

No new tests, covered by existing test that is failing on some platforms.

  • page/EventSource.cpp:

(WebCore::EventSource::responseIsValid const):

LayoutTests:

Dump JS Console messages to stderr for this test as it will only get logged on some
platforms.

Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r277086 r277087  
     12021-05-06  Chris Dumez  <cdumez@apple.com>
     2
     3        imported/w3c/web-platform-tests/eventsource/format-utf-8.htm is failing on some platforms
     4        https://bugs.webkit.org/show_bug.cgi?id=225416
     5        <rdar://77529801>
     6
     7        Reviewed by Youenn Fablet.
     8
     9        Dump JS Console messages to stderr for this test as it will only get logged on some
     10        platforms.
     11
     12        * TestExpectations:
     13
    1142021-05-06  Tim Nguyen  <ntim@apple.com>
    215
  • trunk/LayoutTests/TestExpectations

    r277086 r277087  
    388388
    389389# Console log lines may appear in a different order so we silence them.
     390imported/w3c/web-platform-tests/eventsource/format-utf-8.htm [ DumpJSConsoleLogInStdErr ]
    390391imported/w3c/web-platform-tests/html/browsers/history/the-location-interface/location-protocol-setter-non-broken.html [ DumpJSConsoleLogInStdErr Failure Pass ]
    391392imported/w3c/web-platform-tests/html/browsers/history/the-location-interface/location-protocol-setter-non-broken-weird.html [ DumpJSConsoleLogInStdErr ]
  • trunk/LayoutTests/http/tests/eventsource/eventsource-content-type-charset-expected.txt

    r104803 r277087  
    1 CONSOLE MESSAGE: EventSource's response has a charset ("windows-1251") that is not UTF-8. Aborting the connection.
     1CONSOLE MESSAGE: EventSource's response has a charset ("windows-1251") that is not UTF-8. The response will be decoded as UTF-8.
    22CONSOLE MESSAGE: EventSource's response has a MIME type ("text/event-stream-foobar") that is not "text/event-stream". Aborting the connection.
    33Test for bug 45372: https://bugs.webkit.org/show_bug.cgi?id=45372
  • trunk/LayoutTests/http/tests/eventsource/eventsource-content-type-charset.html

    r272926 r277087  
    4040
    4141var expectedResultCallback = [ shouldGetMessage,
    42                                shouldFail,
     42                               shouldGetMessage,
    4343                               shouldGetMessage,
    4444                               shouldGetMessage,
  • trunk/Source/WebCore/ChangeLog

    r277083 r277087  
     12021-05-06  Chris Dumez  <cdumez@apple.com>
     2
     3        imported/w3c/web-platform-tests/eventsource/format-utf-8.htm is failing on some platforms
     4        https://bugs.webkit.org/show_bug.cgi?id=225416
     5        <rdar://77529801>
     6
     7        Reviewed by Youenn Fablet.
     8
     9        The HTML specification [1] states that EventSource streams should always be decoded as UTF-8.
     10        However, we had logic in WebKit that was checking the charset of the response and aborting
     11        when the charset is not UTF-8. It looks like we were lucky until now that we would fail to
     12        determine the charset of the response and proceed anyway. However, due to underlying system
     13        changes, in the context of this test, we are now properly detecting the response charset as
     14        "windows-1252" and (incorrectly) aborting. To address the issue, I no longer abort the
     15        connection if the charset is not "utf-8". We do still log a console warning but we proceed
     16        decoding the stream as UTF-8 no matter the response's charset, as per the specification.
     17
     18        [1] https://html.spec.whatwg.org/multipage/server-sent-events.html#event-stream-interpretation
     19
     20        No new tests, covered by existing test that is failing on some platforms.
     21
     22        * page/EventSource.cpp:
     23        (WebCore::EventSource::responseIsValid const):
     24
    1252021-05-06  Martin Robinson  <mrobinson@webkit.org>
    226
  • trunk/Source/WebCore/page/EventSource.cpp

    r251244 r277087  
    184184    }
    185185
    186     // If we have a charset, the only allowed value is UTF-8 (case-insensitive).
     186    // The specification states we should always decode as UTF-8. If there is a provided charset and it is not UTF-8, then log a warning
     187    // message but keep going anyway.
    187188    auto& charset = response.textEncodingName();
    188189    if (!charset.isEmpty() && !equalLettersIgnoringASCIICase(charset, "utf-8")) {
    189         auto message = makeString("EventSource's response has a charset (\"", charset, "\") that is not UTF-8. Aborting the connection.");
     190        auto message = makeString("EventSource's response has a charset (\"", charset, "\") that is not UTF-8. The response will be decoded as UTF-8.");
    190191        // FIXME: Console message would be better with a source code location; where would we get that?
    191192        scriptExecutionContext()->addConsoleMessage(MessageSource::JS, MessageLevel::Error, WTFMove(message));
    192         return false;
    193193    }
    194194
Note: See TracChangeset for help on using the changeset viewer.