@@ -906,6 +906,7 @@ ex_diffpatch(exarg_T *eap)
906906 int browse_flag = cmdmod .browse ;
907907#endif
908908 stat_T st ;
909+ char_u * esc_name = NULL ;
909910
910911#ifdef FEAT_BROWSE
911912 if (cmdmod .browse )
@@ -935,11 +936,14 @@ ex_diffpatch(exarg_T *eap)
935936 /* Get the absolute path of the patchfile, changing directory below. */
936937 fullname = FullName_save (eap -> arg , FALSE);
937938#endif
938- buflen = STRLEN ( tmp_orig ) + (
939+ esc_name = vim_strsave_shellescape (
939940# ifdef UNIX
940- fullname != NULL ? STRLEN ( fullname ) :
941+ fullname != NULL ? fullname :
941942# endif
942- STRLEN (eap -> arg )) + STRLEN (tmp_new ) + 16 ;
943+ eap -> arg , TRUE, TRUE);
944+ if (esc_name == NULL )
945+ goto theend ;
946+ buflen = STRLEN (tmp_orig ) + STRLEN (esc_name ) + STRLEN (tmp_new ) + 16 ;
943947 buf = alloc ((unsigned )buflen );
944948 if (buf == NULL )
945949 goto theend ;
@@ -977,17 +981,8 @@ ex_diffpatch(exarg_T *eap)
977981 {
978982 /* Build the patch command and execute it. Ignore errors. Switch to
979983 * cooked mode to allow the user to respond to prompts. */
980- vim_snprintf ((char * )buf , buflen ,
981- #ifdef UNIX
982- "patch -o %s %s < '%s'" ,
983- #else
984- "patch -o %s %s < \"%s\"" ,
985- #endif
986- tmp_new , tmp_orig ,
987- # ifdef UNIX
988- fullname != NULL ? fullname :
989- # endif
990- eap -> arg );
984+ vim_snprintf ((char * )buf , buflen , "patch -o %s %s < %s" ,
985+ tmp_new , tmp_orig , esc_name );
991986#ifdef FEAT_AUTOCMD
992987 block_autocmds (); /* Avoid ShellCmdPost stuff */
993988#endif
@@ -1078,6 +1073,7 @@ ex_diffpatch(exarg_T *eap)
10781073#ifdef UNIX
10791074 vim_free (fullname );
10801075#endif
1076+ vim_free (esc_name );
10811077#ifdef FEAT_BROWSE
10821078 vim_free (browseFile );
10831079 cmdmod .browse = browse_flag ;
0 commit comments