mirror of
https://github.com/kovidgoyal/kitty.git
synced 2026-05-13 08:26:56 +00:00
Escape user input in zsh integration's _ksi_preexec
Also fix a bug in one of the test assertions to make the test work.
This commit is contained in:
parent
909671f508
commit
9549618bc9
2 changed files with 5 additions and 2 deletions
|
|
@ -161,6 +161,9 @@ RPS1="{rps1}"
|
|||
pty.write_to_child('\x04')
|
||||
pty.wait_till(lambda: pty.screen.cursor.shape == CURSOR_BEAM)
|
||||
self.assert_command(pty)
|
||||
# Check escaping of inputs
|
||||
pty.send_cmd_to_child("-f-this-command-must-not-exist")
|
||||
self.assert_command(pty, exit_status=127)
|
||||
with self.run_shell(rc=f'''PS1="{ps1}"''') as pty:
|
||||
pty.callbacks.clear()
|
||||
pty.send_cmd_to_child('printf "%s\x16\a%s" "a" "b"')
|
||||
|
|
@ -273,7 +276,7 @@ function _set_status_prompt; function fish_prompt; echo -n "$pipestatus $status
|
|||
|
||||
def assert_command(self, pty, cmd='', exit_status=0):
|
||||
cmd = cmd or pty.last_cmd
|
||||
pty.wait_till(lambda: pty.callbacks.last_cmd_exit_status == 0, timeout_msg=lambda: f'{pty.callbacks.last_cmd_exit_status=} != {exit_status}')
|
||||
pty.wait_till(lambda: pty.callbacks.last_cmd_exit_status == exit_status, timeout_msg=lambda: f'{pty.callbacks.last_cmd_exit_status=} != {exit_status}')
|
||||
pty.wait_till(lambda: pty.callbacks.last_cmd_cmdline == cmd, timeout_msg=lambda: f'{pty.callbacks.last_cmd_cmdline=!r} != {cmd!r}')
|
||||
|
||||
@unittest.skipUnless(bash_ok(), 'bash not installed, too old, or debug build')
|
||||
|
|
|
|||
|
|
@ -222,7 +222,7 @@ _ksi_deferred_init() {
|
|||
# its preexec hook before us, we'll incorrectly mark its output as
|
||||
# belonging to the command (as if the user typed it into zle) rather
|
||||
# than command output.
|
||||
builtin print -nu "$_ksi_fd" -f '\e]133;C;cmdline=%q\a' "$1"
|
||||
builtin print -nu "$_ksi_fd" -f '\e]133;C;cmdline=%q\a' -- "$1"
|
||||
(( _ksi_state = 1 ))
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue