diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2018-01-21 10:28:52 +0100 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2018-01-21 12:21:47 +0100 |
commit | 456cf72974865cecf489bc5a5b4003c22745a77d (patch) | |
tree | d98b8ded40c7ddaf1becf4d2215b1315aad1ec1b /src | |
parent | ce09d4134b05cfdf6f71bcc93bb5cb9e48e4d9a0 (diff) | |
download | rneovim-456cf72974865cecf489bc5a5b4003c22745a77d.tar.gz rneovim-456cf72974865cecf489bc5a5b4003c22745a77d.tar.bz2 rneovim-456cf72974865cecf489bc5a5b4003c22745a77d.zip |
vim-patch:8.0.0442: patch shell command not well escaped
Problem: Patch shell command uses double quotes around the argument, which
allows for $HOME to be expanded. (Etienne)
Solution: Use single quotes on Unix. (closes vim/vim#1543)
https://github.com/vim/vim/commit/1ef73e33c9414eb02c229d8234aafd9d481a8856
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/diff.c | 2 | ||||
-rw-r--r-- | src/nvim/testdir/test_diffmode.vim | 17 |
2 files changed, 15 insertions, 4 deletions
diff --git a/src/nvim/diff.c b/src/nvim/diff.c index dd489c18e9..4db81a97a2 100644 --- a/src/nvim/diff.c +++ b/src/nvim/diff.c @@ -925,7 +925,7 @@ void ex_diffpatch(exarg_T *eap) } else { // Build the patch command and execute it. Ignore errors. #ifdef UNIX - vim_snprintf((char *)buf, buflen, "patch -o %s %s < \"%s\"", + vim_snprintf((char *)buf, buflen, "patch -o %s %s < '%s'", tmp_new, tmp_orig, fullname != NULL ? fullname : eap->arg); #else vim_snprintf((char *)buf, buflen, "patch -o %s %s < \"%s\"", diff --git a/src/nvim/testdir/test_diffmode.vim b/src/nvim/testdir/test_diffmode.vim index b5a76909a2..430d02c2c3 100644 --- a/src/nvim/testdir/test_diffmode.vim +++ b/src/nvim/testdir/test_diffmode.vim @@ -501,9 +501,20 @@ func Test_diffpatch() bwipe! new call assert_fails('diffpatch Xpatch', 'E816:') - call setline(1, ['1', '2', '3']) - diffpatch Xpatch - call assert_equal(['1', '2x', '3', '4'], getline(1, '$')) + + for name in ['Xpatch', 'Xpatch$HOME'] + call setline(1, ['1', '2', '3']) + if name != 'Xpatch' + call rename('Xpatch', name) + endif + exe 'diffpatch ' . escape(name, '$') + call assert_equal(['1', '2x', '3', '4'], getline(1, '$')) + if name != 'Xpatch' + call rename(name, 'Xpatch') + endif + bwipe! + endfor + call delete('Xpatch') bwipe! endfunc |