mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-04-25 00:51:20 +00:00
fix(cli): sanitize surrogate characters in handle_paste
Prevents UTF-8 encoding crash when pasting text from Word or Google Docs, which may contain lone surrogate code points (U+D800-U+DFFF). Reuses existing _sanitize_surrogates() from run_agent module.
This commit is contained in:
parent
0998a57007
commit
860489600a
1 changed files with 3 additions and 0 deletions
3
cli.py
3
cli.py
|
|
@ -8695,6 +8695,9 @@ class HermesCLI:
|
|||
if _should_auto_attach_clipboard_image_on_paste(pasted_text) and self._try_attach_clipboard_image():
|
||||
event.app.invalidate()
|
||||
if pasted_text:
|
||||
# Sanitize surrogate characters (e.g. from Word/Google Docs paste) before writing
|
||||
from run_agent import _sanitize_surrogates
|
||||
pasted_text = _sanitize_surrogates(pasted_text)
|
||||
line_count = pasted_text.count('\n')
|
||||
buf = event.current_buffer
|
||||
if line_count >= 5 and not buf.text.strip().startswith('/'):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue