Repository navigation
lib,src: reset TextDecoder after a decoding error - #67610
Draft
vedchaudhari wants to merge 1 commit into
Draft
vedchaudhari wants to merge 1 commit into
vedchaudhari wants to merge 1 commit into
Conversation
A fatal decode() error now resets the decoder, as the Encoding Standard requires, so the next call does not continue with the bytes or BOM state from before the error. Signed-off-by: vedchaudhari <vedc2853@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Draft until whatwg/encoding#369 lands.
The spec is changing so that when
TextDecoder#decode()throws in fatal mode, the decoder resets and the next call starts fresh. Node currently keeps the old state, so if you keep streaming after an error:ABas U+758E, and gb18030 leaks a leftover byteThis resets the decoder when an error happens, for UTF-8 (in JS) and the ICU encodings (in C++), and nothing changes when fatal is off. I added tests for it and also checked it against the new WPT tests from the WebKit PR, which all pass now.
cc @ChALkeR since you wrote the UTF-8 fast path and opened whatwg/encoding#359.
Fixes: #67604
Refs: whatwg/encoding#369
Assisted-by: an AI coding agent. Reviewed and tested locally by me.