fix(cli): sanitize surrogate characters in _on_text_changed paste fallback#9158
Closed
XiaoXiao0221 wants to merge 2 commits intoNousResearch:mainfrom
Closed
fix(cli): sanitize surrogate characters in _on_text_changed paste fallback#9158XiaoXiao0221 wants to merge 2 commits intoNousResearch:mainfrom
XiaoXiao0221 wants to merge 2 commits intoNousResearch:mainfrom
Conversation
…tirith binary - Add Windows platform detection in _detect_target() (pc-windows-msvc) - Use .zip archive for Windows targets instead of .tar.gz - Implement zipfile extraction for Windows binary (tirith.exe) - Fix path resolution bug where src_base ignored nested zip members - Skip chmod +x on Windows (not supported) - Add unit test script for cross-platform archive handling Fixes: WinError 2 file not found when tirith auto-installs on Windows
…lback The handle_paste function (BracketedPaste mode) was already sanitized in PR NousResearch#8980. The _on_text_changed fallback path that fires when bracketed paste is not available also writes pasted text to a file without sanitizing, causing UnicodeEncodeError when text contains lone surrogates from Word/Google Docs clipboard paste. Add _sanitize_surrogates() call before write_text() in the fallback handler, matching the same protection already applied to the primary handle_paste path.
Contributor
Author
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.
What does this PR do?
Fix UnicodeEncodeError when pasting text containing lone surrogates (e.g. from Google Docs / Word clipboard) in terminals that do not support Bracketed Paste mode.
handle_paste (BracketedPaste) was already sanitized in PR #8980. The _on_text_changed fallback path that fires when bracketed paste is unavailable was missing the same sanitization, causing:
Related Issue
Follow-up to #8980.
Type of Change
Changes Made
cli.py: Added_sanitize_surrogates()call beforepaste_file.write_text()in the_on_text_changedfallback paste handlerHow to Test
Checklist
fix(cli):)