forked from aniani/vim
updated for version 7.3.025
Problem: ":mksession" does not square brackets escape file name properly. Solution: Improve escapging of file names. (partly by Peter Odding)
This commit is contained in:
parent
a4f332b44c
commit
78f74a91bf
@ -10708,7 +10708,7 @@ ses_fname(fd, buf, flagp)
|
|||||||
* Write a file name to the session file.
|
* Write a file name to the session file.
|
||||||
* Takes care of the "slash" option in 'sessionoptions' and escapes special
|
* Takes care of the "slash" option in 'sessionoptions' and escapes special
|
||||||
* characters.
|
* characters.
|
||||||
* Returns FAIL if writing fails.
|
* Returns FAIL if writing fails or out of memory.
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
ses_put_fname(fd, name, flagp)
|
ses_put_fname(fd, name, flagp)
|
||||||
@ -10717,49 +10717,32 @@ ses_put_fname(fd, name, flagp)
|
|||||||
unsigned *flagp;
|
unsigned *flagp;
|
||||||
{
|
{
|
||||||
char_u *sname;
|
char_u *sname;
|
||||||
|
char_u *p;
|
||||||
int retval = OK;
|
int retval = OK;
|
||||||
int c;
|
|
||||||
|
|
||||||
sname = home_replace_save(NULL, name);
|
sname = home_replace_save(NULL, name);
|
||||||
if (sname != NULL)
|
if (sname == NULL)
|
||||||
name = sname;
|
return FAIL;
|
||||||
while (*name != NUL)
|
|
||||||
{
|
|
||||||
#ifdef FEAT_MBYTE
|
|
||||||
{
|
|
||||||
int l;
|
|
||||||
|
|
||||||
if (has_mbyte && (l = (*mb_ptr2len)(name)) > 1)
|
if (*flagp & SSOP_SLASH)
|
||||||
{
|
{
|
||||||
/* copy a multibyte char */
|
/* change all backslashes to forward slashes */
|
||||||
while (--l >= 0)
|
for (p = sname; *p != NUL; mb_ptr_adv(p))
|
||||||
{
|
if (*p == '\\')
|
||||||
if (putc(*name, fd) != *name)
|
*p = '/';
|
||||||
retval = FAIL;
|
|
||||||
++name;
|
|
||||||
}
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
c = *name++;
|
|
||||||
if (c == '\\' && (*flagp & SSOP_SLASH))
|
|
||||||
/* change a backslash to a forward slash */
|
|
||||||
c = '/';
|
|
||||||
else if ((vim_strchr(escape_chars, c) != NULL
|
|
||||||
#ifdef BACKSLASH_IN_FILENAME
|
|
||||||
&& c != '\\'
|
|
||||||
#endif
|
|
||||||
) || c == '#' || c == '%')
|
|
||||||
{
|
|
||||||
/* escape a special character with a backslash */
|
|
||||||
if (putc('\\', fd) != '\\')
|
|
||||||
retval = FAIL;
|
|
||||||
}
|
|
||||||
if (putc(c, fd) != c)
|
|
||||||
retval = FAIL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* escapse special characters */
|
||||||
|
p = vim_strsave_fnameescape(sname, FALSE);
|
||||||
vim_free(sname);
|
vim_free(sname);
|
||||||
|
if (p == NULL)
|
||||||
|
return FAIL;
|
||||||
|
|
||||||
|
/* write the result */
|
||||||
|
if (fputs((char *)p, fd) < 0)
|
||||||
|
retval = FAIL;
|
||||||
|
|
||||||
|
vim_free(p);
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -714,6 +714,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
25,
|
||||||
/**/
|
/**/
|
||||||
24,
|
24,
|
||||||
/**/
|
/**/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user