[SCM] Vim packaging branch, maint/lenny, updated. debian/7.1.314-3-51-g209709e
James Vega
jamessan at debian.org
Sun Oct 12 06:29:11 UTC 2008
The following commit has been merged in the maint/lenny branch:
commit 831a705132fb021d6f7f0118f464bcd4ee8dafa7
Author: James Vega <jamessan at debian.org>
Date: Thu Oct 9 21:53:37 2008 -0400
[7.2b.005] shellescape() doesn't take care of "!" and "\n"
Patch 7.2b.005
Problem: The special character "!" isn't handled properly in shellescape().
(Jan Minar)
Solution: Escape "!" when using a "csh" like shell and with
shellescape(s, 1). Twice for both. Also escape <NL>.
Conflicts:
src/version.c
Signed-off-by: James Vega <jamessan at debian.org>
diff --git a/debian/README b/debian/README
index df96301..5f639da 100644
--- a/debian/README
+++ b/debian/README
@@ -347,3 +347,5 @@ Individual patches for Vim 7.1:
2346 7.1.312 there is no check for error number mistakes in .po files
3425 7.1.313 status and tile not updated when using netbeans setModified
1915 7.1.314 'pastetoggle' is written to the session file without escaping
+ 20111 7.2a.013 shellescape() does not escape "%" and "#" characters
+ 3465 7.2b.005 shellescape() doesn't take care of "!" and "\n"
diff --git a/src/misc2.c b/src/misc2.c
index fee0a4d..6712f38 100644
--- a/src/misc2.c
+++ b/src/misc2.c
@@ -1265,7 +1265,9 @@ vim_strsave_escaped_ext(string, esc_chars, cc, bsl)
* Escape "string" for use as a shell argument with system().
* This uses single quotes, except when we know we need to use double qoutes
* (MS-DOS and MS-Windows without 'shellslash' set).
- * Also replace "%", "#" and things like "<cfile>" when "do_special" is TRUE.
+ * Escape a newline, depending on the 'shell' option.
+ * When "do_special" is TRUE also replace "!", "%", "#" and things starting
+ * with "<" like "<cfile>".
* Returns the result in allocated memory, NULL if we have run out.
*/
char_u *
@@ -1278,6 +1280,13 @@ vim_strsave_shellescape(string, do_special)
char_u *d;
char_u *escaped_string;
int l;
+ int csh_like;
+
+ /* Only csh and similar shells expand '!' within single quotes. For sh and
+ * the like we must not put a backslash before it, it will be taken
+ * literally. If do_special is set the '!' will be escaped twice.
+ * Csh also needs to have "\n" escaped twice when do_special is set. */
+ csh_like = (strstr((char *)gettail(p_sh), "csh") != NULL);
/* First count the number of extra bytes required. */
length = (unsigned)STRLEN(string) + 3; /* two quotes and a trailing NUL */
@@ -1293,6 +1302,12 @@ vim_strsave_shellescape(string, do_special)
# endif
if (*p == '\'')
length += 3; /* ' => '\'' */
+ if (*p == '\n' || (*p == '!' && (csh_like || do_special)))
+ {
+ ++length; /* insert backslash */
+ if (csh_like && do_special)
+ ++length; /* insert backslash */
+ }
if (do_special && find_cmdline_var(p, &l) >= 0)
{
++length; /* insert backslash */
@@ -1338,6 +1353,14 @@ vim_strsave_shellescape(string, do_special)
++p;
continue;
}
+ if (*p == '\n' || (*p == '!' && (csh_like || do_special)))
+ {
+ *d++ = '\\';
+ if (csh_like && do_special)
+ *d++ = '\\';
+ *d++ = *p++;
+ continue;
+ }
if (do_special && find_cmdline_var(p, &l) >= 0)
{
*d++ = '\\'; /* insert backslash */
--
Vim packaging
More information about the pkg-vim-maintainers
mailing list