Repository navigation
Allow valid UTF-8 replacement characters in flutter_tools decoding - #188901
Merged
auto-submit[bot] merged 3 commits intoAug 5, 2026
Merged
auto-submit[bot] merged 3 commits into
auto-submit[bot] merged 3 commits into
Conversation
Contributor
There was a problem hiding this comment.
Code Review
This pull request updates Utf8Decoder to use a strict UTF-8 decoder when reportErrors is enabled, catching FormatException during direct conversion to throw a descriptive ToolExit. It also adds tests to verify decoding behavior with valid replacement characters and malformed bytes. Feedback indicates a potential regression where using the strict decoder for chunked conversion, stream binding, and fusing could cause unhandled FormatException crashes, as these paths lack the error-handling wrapper implemented in the convert method.
bkonyi
approved these changes
Aug 5, 2026
bkonyi
left a comment
Contributor
There was a problem hiding this comment.
Thanks for the contribution! LGTM!
chingjun
approved these changes
Aug 5, 2026
This was referenced Aug 6, 2026
LinXunFeng
deleted the
fix/flutter-tools-valid-replacement-character-utf8
branch
August 7, 2026 04:33
This was referenced Aug 7, 2026
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.
Fixes #177509
This updates
flutter_toolsUTF-8 error detection so that a validU+FFFDreplacement character is not mistaken for malformed UTF-8.Previously,
Utf8Decoderdecoded bytes withallowMalformed: trueand then treated any decoded string containingU+FFFDas evidence that the original bytes were malformed. That incorrectly rejects valid UTF-8 input such asEF BF BD, which is the legitimate encoding ofU+FFFD.This PR changes the decoder to use a strict UTF-8 decoder when
reportErrorsis enabled. If strict decoding succeeds, the decoded string is returned as-is. If strict decoding throwsFormatException, the input is decoded again withallowMalformed: trueonly to preserve the existingToolExitdiagnostic message and source bytes.The permissive
reportErrors: falsepath is unchanged and continues to decode malformed bytes with replacement characters.///).