mirror of
https://github.com/vim/vim.git
synced 2025-09-24 03:44:06 -04:00
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)
This commit is contained in:
@@ -977,7 +977,12 @@ ex_diffpatch(exarg_T *eap)
|
|||||||
{
|
{
|
||||||
/* Build the patch command and execute it. Ignore errors. Switch to
|
/* Build the patch command and execute it. Ignore errors. Switch to
|
||||||
* cooked mode to allow the user to respond to prompts. */
|
* 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,
|
tmp_new, tmp_orig,
|
||||||
# ifdef UNIX
|
# ifdef UNIX
|
||||||
fullname != NULL ? fullname :
|
fullname != NULL ? fullname :
|
||||||
|
@@ -318,9 +318,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
|
||||||
|
@@ -764,6 +764,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
442,
|
||||||
/**/
|
/**/
|
||||||
441,
|
441,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user