mirror of
https://github.com/kovidgoyal/kitty.git
synced 2026-08-31 06:18:17 +00:00
Always ask for confirmation when pasting text with control codes in it
This commit is contained in:
parent
56963c693e
commit
defa2e29ac
7 changed files with 32 additions and 19 deletions
|
|
@ -1135,16 +1135,13 @@ def docs_url(which: str = '', local_docs_root: Optional[str] = '') -> str:
|
|||
return url
|
||||
|
||||
|
||||
def sanitize_for_bracketed_paste(text: bytes, at_shell_prompt: bool = False) -> bytes:
|
||||
def sanitize_for_bracketed_paste(text: bytes) -> bytes:
|
||||
pat = re.compile(b'(?:(?:\033\\\x5b)|(?:\x9b))201~')
|
||||
while True:
|
||||
new_text = pat.sub(b'', text)
|
||||
if new_text == text:
|
||||
break
|
||||
text = new_text
|
||||
if at_shell_prompt:
|
||||
# some shells dont handle C0 control codes in pasted text correctly
|
||||
text = re.sub(b'[\x00-\x1f]+', b'', text)
|
||||
return text
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue