mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-18 22:44:50 +02:00
Always ask for confirmation when pasting text with control codes in it
This commit is contained in:
@@ -523,7 +523,7 @@ clipboard.
|
||||
'''
|
||||
)
|
||||
|
||||
opt('paste_actions', 'quote-urls-at-prompt',
|
||||
opt('paste_actions', 'quote-urls-at-prompt,confirm',
|
||||
option_type='paste_actions',
|
||||
long_text='''
|
||||
A comma separated list of actions to take when pasting text into the terminal.
|
||||
@@ -533,8 +533,12 @@ The supported paste actions are:
|
||||
If the text being pasted is a URL and the cursor is at a shell prompt,
|
||||
automatically quote the URL (needs :opt:`shell_integration`).
|
||||
:code:`confirm`:
|
||||
Confirm the paste if bracketed paste mode is not active or there is
|
||||
a large amount of text being pasted.
|
||||
Confirm the paste if the text to be pasted contains any terminal control codes
|
||||
as this can be dangerous, leading to code execution if the shell/program running
|
||||
in the terminal does not properly handle these.
|
||||
:code:`confirm-if-large`
|
||||
Confirm the paste if it is very large (larger than 16KB) as pasting
|
||||
large amounts of text into shells can be very slow.
|
||||
:code:`filter`:
|
||||
Run the filter_paste() function from the file :file:`paste-actions.py` in
|
||||
the kitty config directory on the pasted text. The text returned by the
|
||||
|
||||
2
kitty/options/types.py
generated
2
kitty/options/types.py
generated
@@ -544,7 +544,7 @@ class Options:
|
||||
mark3_foreground: Color = Color(0, 0, 0)
|
||||
mouse_hide_wait: float = 0.0 if is_macos else 3.0
|
||||
open_url_with: typing.List[str] = ['default']
|
||||
paste_actions: typing.FrozenSet[str] = frozenset({'quote-urls-at-prompt'})
|
||||
paste_actions: typing.FrozenSet[str] = frozenset({'confirm', 'quote-urls-at-prompt'})
|
||||
placement_strategy: choices_for_placement_strategy = 'center'
|
||||
pointer_shape_when_dragging: choices_for_pointer_shape_when_dragging = 'beam'
|
||||
pointer_shape_when_grabbed: choices_for_pointer_shape_when_grabbed = 'arrow'
|
||||
|
||||
@@ -911,7 +911,7 @@ def shell_integration(x: str) -> FrozenSet[str]:
|
||||
|
||||
|
||||
def paste_actions(x: str) -> FrozenSet[str]:
|
||||
s = frozenset({'quote-urls-at-prompt', 'confirm', 'filter'})
|
||||
s = frozenset({'quote-urls-at-prompt', 'confirm', 'filter', 'confirm-if-large'})
|
||||
q = frozenset(x.lower().split(','))
|
||||
if not q.issubset(s):
|
||||
log_error(f'Invalid paste actions: {q - s}, ignoring')
|
||||
|
||||
Reference in New Issue
Block a user