Hi list,
After changing my session.vim* plug-in to use :mksession and using the
plug-in for a while I found that :mksession sometimes fails to properly
escape filenames in session scripts. I'm attaching a Vim script that
should demonstrate the problem when executed like this in Vim 7.3:
$ vim -u NONE --noplugin -NS mksession-E16-bug.vim
I'm also attaching a patch against the latest Vim 7.3 which fixes the
problem for me, however I don't know whether it's the best approach.
- Peter Odding
* http://www.vim.org/scripts/script.php?script_id=3150
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
" Note: These files will be created in your working directory.
let badbufname = '[xxxxxxx #xxx-555364]: xxx xx. xxx xxxxxxx.xxx'
let badsession = 'badsession.vim'
" Create the file {badbufname} and demonstrate that fnameescape()
" properly escapes the filename (no E16 error is thrown here).
execute 'write' fnameescape(badbufname)
" Generate a session with :mksession that demonstrates the problem.
execute 'mksession' badsession
" Try to restore the session. This throws two "E16: Invalid range"
" errors for me (running Vim 7.3 with patches 1-6 on UNIX) because the
" character '[' in the arguments to :badd and :edit isn't escaped.
execute 'source' badsession
diff -r 06aa43dde561 src/ex_docmd.c
--- a/src/ex_docmd.c Sat Sep 18 13:36:49 2010 +0200
+++ b/src/ex_docmd.c Sun Sep 19 12:34:18 2010 +0200
@@ -10750,7 +10750,7 @@
#ifdef BACKSLASH_IN_FILENAME
&& c != '\\'
#endif
- ) || c == '#' || c == '%')
+ ) || c == '#' || c == '%' || c == '[')
{
/* escape a special character with a backslash */
if (putc('\\', fd) != '\\')