To: vim-dev@vim.org Subject: Patch 7.2c.002 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit ------------ Patch 7.2c.002 Problem: fnameescape() doesn't handle a leading '+' or '>'. (Jan Minar) Solution: Escape a leading '+' and '>'. And a single '-'. Files: runtime/doc/eval.txt, src/ex_getln.c *** ../vim-7.2c.001/runtime/doc/eval.txt Fri Aug 8 12:35:03 2008 --- runtime/doc/eval.txt Fri Aug 8 11:33:35 2008 *************** *** 2832,2842 **** For most systems the characters escaped are " \t\n*?[{`$\\%#'\"|!<". For systems where a backslash appears in a filename, it depends on the value of 'isfname'. Example: > ! :let fname = 'some str%nge|name' :exe "edit " . fnameescape(fname) < results in executing: > ! edit some\ str\%nge\|name fnamemodify({fname}, {mods}) *fnamemodify()* Modify file name {fname} according to {mods}. {mods} is a --- 2832,2844 ---- For most systems the characters escaped are " \t\n*?[{`$\\%#'\"|!<". For systems where a backslash appears in a filename, it depends on the value of 'isfname'. + A leading '+' and '>' is also escaped (special after |:edit| + and |:write|). And a "-" by itself (special after |:cd|). Example: > ! :let fname = '+some str%nge|name' :exe "edit " . fnameescape(fname) < results in executing: > ! edit \+some\ str\%nge\|name fnamemodify({fname}, {mods}) *fnamemodify()* Modify file name {fname} according to {mods}. {mods} is a *** ../vim-7.2c.001/src/ex_getln.c Wed Aug 6 15:02:43 2008 --- src/ex_getln.c Fri Aug 8 11:31:33 2008 *************** *** 3717,3723 **** if ((*p != '[' && *p != '{') || !vim_isfilec(*p)) buf[j++] = *p; buf[j] = NUL; ! return vim_strsave_escaped(fname, buf); #else p = vim_strsave_escaped(fname, shell ? SHELL_ESC_CHARS : PATH_ESC_CHARS); if (shell && csh_like_shell() && p != NULL) --- 3717,3723 ---- if ((*p != '[' && *p != '{') || !vim_isfilec(*p)) buf[j++] = *p; buf[j] = NUL; ! p = vim_strsave_escaped(fname, buf); #else p = vim_strsave_escaped(fname, shell ? SHELL_ESC_CHARS : PATH_ESC_CHARS); if (shell && csh_like_shell() && p != NULL) *************** *** 3730,3737 **** vim_free(p); p = s; } - return p; #endif } /* --- 3730,3743 ---- vim_free(p); p = s; } #endif + + /* '>' and '+' are special at the start of some commands, e.g. ":edit" and + * ":write". "cd -" has a special meaning. */ + if (*p == '>' || *p == '+' || (*p == '-' && p[1] == NUL)) + escape_fname(&p); + + return p; } /* *** ../vim-7.2c.001/src/version.c Fri Aug 8 12:35:03 2008 --- src/version.c Fri Aug 8 12:56:06 2008 *************** *** 678,679 **** --- 678,681 ---- { /* Add new patch number below this line */ + /**/ + 2, /**/ -- Permission is granted to read this message out aloud on Kings Cross Road, London, under the condition that the orator is properly dressed. /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ download, build and distribute -- http://www.A-A-P.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///