Mercurial > vim
changeset 11109:0adcfcf22036 v8.0.0442
patch 8.0.0442: patch shell command not well escaped
commit https://github.com/vim/vim/commit/1ef73e33c9414eb02c229d8234aafd9d481a8856
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Mar 9 19:21:30 2017 +0100
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 #1543)
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Thu, 09 Mar 2017 19:30:05 +0100 |
parents | 6c7a4a958393 |
children | 0ca13197bbc6 |
files | src/diff.c src/testdir/test_diffmode.vim src/version.c |
diffstat | 3 files changed, 22 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/src/diff.c +++ b/src/diff.c @@ -977,7 +977,12 @@ ex_diffpatch(exarg_T *eap) { /* Build the patch command and execute it. Ignore errors. Switch to * cooked mode to allow the user to respond to prompts. */ - vim_snprintf((char *)buf, buflen, "patch -o %s %s < \"%s\"", + vim_snprintf((char *)buf, buflen, +#ifdef UNIX + "patch -o %s %s < '%s'", +#else + "patch -o %s %s < \"%s\"", +#endif tmp_new, tmp_orig, # ifdef UNIX fullname != NULL ? fullname :
--- a/src/testdir/test_diffmode.vim +++ b/src/testdir/test_diffmode.vim @@ -318,9 +318,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