mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
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)
1ef73e33c9
This commit is contained in:
parent
ce09d4134b
commit
456cf72974
@ -925,7 +925,7 @@ void ex_diffpatch(exarg_T *eap)
|
|||||||
} else {
|
} else {
|
||||||
// Build the patch command and execute it. Ignore errors.
|
// Build the patch command and execute it. Ignore errors.
|
||||||
#ifdef UNIX
|
#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);
|
tmp_new, tmp_orig, fullname != NULL ? fullname : eap->arg);
|
||||||
#else
|
#else
|
||||||
vim_snprintf((char *)buf, buflen, "patch -o %s %s < \"%s\"",
|
vim_snprintf((char *)buf, buflen, "patch -o %s %s < \"%s\"",
|
||||||
|
@ -501,9 +501,20 @@ func Test_diffpatch()
|
|||||||
bwipe!
|
bwipe!
|
||||||
new
|
new
|
||||||
call assert_fails('diffpatch Xpatch', 'E816:')
|
call assert_fails('diffpatch Xpatch', 'E816:')
|
||||||
call setline(1, ['1', '2', '3'])
|
|
||||||
diffpatch Xpatch
|
for name in ['Xpatch', 'Xpatch$HOME']
|
||||||
call assert_equal(['1', '2x', '3', '4'], getline(1, '$'))
|
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')
|
call delete('Xpatch')
|
||||||
bwipe!
|
bwipe!
|
||||||
endfunc
|
endfunc
|
||||||
|
Loading…
Reference in New Issue
Block a user