Mercurial > vim
comparison src/diff.c @ 11113:081ed9efb5c0 v8.0.0444
patch 8.0.0444: diffpatch fails when the file name has a quote
commit https://github.com/vim/vim/commit/a95ab321200f0239991bf53756b17cd7b90745f9
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Mar 11 19:21:53 2017 +0100
patch 8.0.0444: diffpatch fails when the file name has a quote
Problem: Diffpatch fails when the file name has a quote.
Solution: Escape the name properly. (zetzei)
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sat, 11 Mar 2017 19:30:04 +0100 |
parents | 0adcfcf22036 |
children | 778c10516955 |
comparison
equal
deleted
inserted
replaced
11112:a8a5b45fc29f | 11113:081ed9efb5c0 |
---|---|
904 #ifdef FEAT_BROWSE | 904 #ifdef FEAT_BROWSE |
905 char_u *browseFile = NULL; | 905 char_u *browseFile = NULL; |
906 int browse_flag = cmdmod.browse; | 906 int browse_flag = cmdmod.browse; |
907 #endif | 907 #endif |
908 stat_T st; | 908 stat_T st; |
909 char_u *esc_name = NULL; | |
909 | 910 |
910 #ifdef FEAT_BROWSE | 911 #ifdef FEAT_BROWSE |
911 if (cmdmod.browse) | 912 if (cmdmod.browse) |
912 { | 913 { |
913 browseFile = do_browse(0, (char_u *)_("Patch file"), | 914 browseFile = do_browse(0, (char_u *)_("Patch file"), |
933 | 934 |
934 #ifdef UNIX | 935 #ifdef UNIX |
935 /* Get the absolute path of the patchfile, changing directory below. */ | 936 /* Get the absolute path of the patchfile, changing directory below. */ |
936 fullname = FullName_save(eap->arg, FALSE); | 937 fullname = FullName_save(eap->arg, FALSE); |
937 #endif | 938 #endif |
938 buflen = STRLEN(tmp_orig) + ( | 939 esc_name = vim_strsave_shellescape( |
939 # ifdef UNIX | 940 # ifdef UNIX |
940 fullname != NULL ? STRLEN(fullname) : | 941 fullname != NULL ? fullname : |
941 # endif | 942 # 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; | |
943 buf = alloc((unsigned)buflen); | 947 buf = alloc((unsigned)buflen); |
944 if (buf == NULL) | 948 if (buf == NULL) |
945 goto theend; | 949 goto theend; |
946 | 950 |
947 #ifdef UNIX | 951 #ifdef UNIX |
975 else | 979 else |
976 #endif | 980 #endif |
977 { | 981 { |
978 /* Build the patch command and execute it. Ignore errors. Switch to | 982 /* Build the patch command and execute it. Ignore errors. Switch to |
979 * cooked mode to allow the user to respond to prompts. */ | 983 * cooked mode to allow the user to respond to prompts. */ |
980 vim_snprintf((char *)buf, buflen, | 984 vim_snprintf((char *)buf, buflen, "patch -o %s %s < %s", |
981 #ifdef UNIX | 985 tmp_new, tmp_orig, esc_name); |
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); | |
991 #ifdef FEAT_AUTOCMD | 986 #ifdef FEAT_AUTOCMD |
992 block_autocmds(); /* Avoid ShellCmdPost stuff */ | 987 block_autocmds(); /* Avoid ShellCmdPost stuff */ |
993 #endif | 988 #endif |
994 (void)call_shell(buf, SHELL_FILTER | SHELL_COOKED); | 989 (void)call_shell(buf, SHELL_FILTER | SHELL_COOKED); |
995 #ifdef FEAT_AUTOCMD | 990 #ifdef FEAT_AUTOCMD |
1076 vim_free(newname); | 1071 vim_free(newname); |
1077 vim_free(buf); | 1072 vim_free(buf); |
1078 #ifdef UNIX | 1073 #ifdef UNIX |
1079 vim_free(fullname); | 1074 vim_free(fullname); |
1080 #endif | 1075 #endif |
1076 vim_free(esc_name); | |
1081 #ifdef FEAT_BROWSE | 1077 #ifdef FEAT_BROWSE |
1082 vim_free(browseFile); | 1078 vim_free(browseFile); |
1083 cmdmod.browse = browse_flag; | 1079 cmdmod.browse = browse_flag; |
1084 #endif | 1080 #endif |
1085 } | 1081 } |