Created attachment 446414 [details] Sample to show that this bug affects page loading. WPT tests: https://wpt.fyi/results/encoding/textdecoder-eof.any.html?label=experimental&label=master&aligned (also tests for bug 233921). When the TextCodecUTF8 decoder finds a non-ASCII lead byte, it waits until enough bytes are consumed to make a valid sequence starting at that position, before starting to process the bytes. But if the stream is flushed before that, the decoder assumes that the remaining bytes are part of a truncated partial sequence, and so discards them while emitting a single replacement character. But this assumption doesn't necessarily hold, and it can result in non-replacement characters being skipped: // "�A" in Firefox and Chromium 98, and according to the spec. // "��A" in earlier versions of Chromium. // "�" in WebKit. new TextDecoder().decode(new Uint8Array([0xF0, 0x9F, 0x41])); This can also result in fewer replacement characters being emitted than should be the case: // "��A" in Firefox, Chrome, and according to the spec. // "�" in WebKit. new TextDecoder().decode(new Uint8Array([0xF0, 0x80, 0x41])); This bug also affects page loading, as with the attached sample.
*** This bug has been marked as a duplicate of bug 233921 ***
This will be fixed with the same fix as bug 233921