Skip to content

Meta sends escape enabled while running filter from "autocmd" #5617

@antofthy

Description

@antofthy

Describe the bug
After upgrading to Vim-8.2 the 'xterm modifyOtherKeys' patch has caused issues with me... I use "autocmd" to read in a binary encrypted file, which is then decrypted using a password read directly from the users TTY.

If I read from the xterm TTY from the command run from "autocmd" and I type 'A' I get the input '\e[27;2;65~' which is the ANSI code for a 'Shifted-A' and not an actual 'A'. As you can imagine the password is then wrong, the the command fails to decrypt the file I want to edit. Only a problem if the passwords contain shifted characters in it!

If I use a :%!command directly, there is no problem... So VIM is disabling the 'xterm modifyOtherKeys' it for that. It only becomes a problem when I do this from a "autocmd".

This sort of "autocmd" input is what would be used by commands like "gpg" and "openssl enc" to encrypt and decrypt files via vim "autocmd" and this is currently failing!

To Reproduce
run vim file.test in a xterm does not matter if the file does not exist

Inside vim...

:" check t_TI is set to t_TI=^[[>4;2m
:set t_TI
:" Set an autocommand to read from TTY
:autocmd  BufWritePre,FileWritePre   *.test !bash -c 'cat </dev/tty >/dev/tty'
:" now write the file to run the above autocmd
:w

The command will not be waiting from some input from the TTY...
type 'A' and you will see the resulting ANSI sequence.

You can not even type ctrl-D to terminate the above, and will need to kill the "cat" from another terminal!

If you did the command directly without using autocmd, EG:

" Direct shell call
:!bash -c 'cat </dev/tty >/dev/tty'

It works perfectly fine. The problem only happens from autocmd, for both call '!' or filter '|' shell commands.

Expected behavior
Input should be what the user typed, not ANSI escape sequences.

Environment (please complete the following information):
Fedora Packages:
vim-common-8.2.109-1.fc31
vim-enhanced-8.2.109-1.fc31
vim-filesystem-8.2.109-1.fc31

vim --version
VIM - Vi IMproved 8.2 (2019 Dec 12, compiled Jan 10 2020 00:00:00)
Included patches: 1-109
Modified by bugzilla@redhat.com
Compiled by bugzilla@redhat.com

Terminal xterm-351-1.fc31
TERM=xterm-256color

Additional context
This appears to be the reason the patch was added...
#4974 (comment)

A temporary fix was provided in
#5200 and #5612 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions