Fix UnicodeDecodeError crash on invalid UTF-8 input (#6456)#6498
Open
hamza-mobeen wants to merge 2 commits intoTextualize:mainfrom
Open
Fix UnicodeDecodeError crash on invalid UTF-8 input (#6456)#6498hamza-mobeen wants to merge 2 commits intoTextualize:mainfrom
hamza-mobeen wants to merge 2 commits intoTextualize:mainfrom
Conversation
Author
|
Hello @willmcgugan, Please find the proposed fix for issue #6456 attached for your review. This addresses the UnicodeDecodeError threading crashes by implementing a resilient byte replacement strategy across all three input drivers, complete with regression tests. I look forward to your feedback. |
Member
|
Your tests aren’t testing the code you changed. A regression tests should fail without your change. Yours pass. |
Author
@willmcgugan hello, hope you good, I've re written the test, you can check it out when you free. thanks for the feedback |
Author
|
hello @willmcgugan |
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.
Link to issue or discussion
#6456
Summary
The UTF-8 incremental decoders in
LinuxDriver,LinuxInlineDriver, andWebDriverdefault toerrors="strict", which raisesUnicodeDecodeErrorwhen invalid byte sequences are received from the terminal. This kills the input thread and leaves the application unresponsive with no recovery.This PR changes the decoder to use
errors="replace", which substitutes the Unicode replacement character (U+FFFD) for any invalid bytes, matching the behavior described in the issue.Changes
src/textual/drivers/linux_driver.py— line 415:errors="replace"src/textual/drivers/linux_inline_driver.py— line 133:errors="replace"src/textual/drivers/web_driver.py— line 188:errors="replace"tests/test_utf8_decode_resilience.py— new regression test (3 test cases)AI Disclosure
This PR was generated with the assistance of an AI agent (Antigravity by Google DeepMind). It follows the project's AI_POLICY.md and links to the approved issue above.