]>
Commit | Line | Data |
---|---|---|
17e7d110 SS |
1 | To: vim-dev@vim.org |
2 | Subject: Patch 7.3.025 | |
3 | Fcc: outbox | |
4 | From: Bram Moolenaar <Bram@moolenaar.net> | |
5 | Mime-Version: 1.0 | |
6 | Content-Type: text/plain; charset=UTF-8 | |
7 | Content-Transfer-Encoding: 8bit | |
8 | ------------ | |
9 | ||
10 | Patch 7.3.025 | |
11 | Problem: ":mksession" does not square brackets escape file name properly. | |
12 | Solution: Improve escapging of file names. (partly by Peter Odding) | |
13 | Files: src/ex_docmd.c | |
14 | ||
15 | ||
16 | *** ../vim-7.3.024/src/ex_docmd.c 2010-09-21 16:56:29.000000000 +0200 | |
17 | --- src/ex_docmd.c 2010-10-13 17:39:17.000000000 +0200 | |
18 | *************** | |
19 | *** 10708,10714 **** | |
20 | * Write a file name to the session file. | |
21 | * Takes care of the "slash" option in 'sessionoptions' and escapes special | |
22 | * characters. | |
23 | ! * Returns FAIL if writing fails. | |
24 | */ | |
25 | static int | |
26 | ses_put_fname(fd, name, flagp) | |
27 | --- 10708,10714 ---- | |
28 | * Write a file name to the session file. | |
29 | * Takes care of the "slash" option in 'sessionoptions' and escapes special | |
30 | * characters. | |
31 | ! * Returns FAIL if writing fails or out of memory. | |
32 | */ | |
33 | static int | |
34 | ses_put_fname(fd, name, flagp) | |
35 | *************** | |
36 | *** 10717,10765 **** | |
37 | unsigned *flagp; | |
38 | { | |
39 | char_u *sname; | |
40 | int retval = OK; | |
41 | - int c; | |
42 | ||
43 | sname = home_replace_save(NULL, name); | |
44 | ! if (sname != NULL) | |
45 | ! name = sname; | |
46 | ! while (*name != NUL) | |
47 | ! { | |
48 | ! #ifdef FEAT_MBYTE | |
49 | ! { | |
50 | ! int l; | |
51 | ||
52 | ! if (has_mbyte && (l = (*mb_ptr2len)(name)) > 1) | |
53 | ! { | |
54 | ! /* copy a multibyte char */ | |
55 | ! while (--l >= 0) | |
56 | ! { | |
57 | ! if (putc(*name, fd) != *name) | |
58 | ! retval = FAIL; | |
59 | ! ++name; | |
60 | ! } | |
61 | ! continue; | |
62 | ! } | |
63 | ! } | |
64 | ! #endif | |
65 | ! c = *name++; | |
66 | ! if (c == '\\' && (*flagp & SSOP_SLASH)) | |
67 | ! /* change a backslash to a forward slash */ | |
68 | ! c = '/'; | |
69 | ! else if ((vim_strchr(escape_chars, c) != NULL | |
70 | ! #ifdef BACKSLASH_IN_FILENAME | |
71 | ! && c != '\\' | |
72 | ! #endif | |
73 | ! ) || c == '#' || c == '%') | |
74 | ! { | |
75 | ! /* escape a special character with a backslash */ | |
76 | ! if (putc('\\', fd) != '\\') | |
77 | ! retval = FAIL; | |
78 | ! } | |
79 | ! if (putc(c, fd) != c) | |
80 | ! retval = FAIL; | |
81 | } | |
82 | vim_free(sname); | |
83 | return retval; | |
84 | } | |
85 | ||
86 | --- 10717,10748 ---- | |
87 | unsigned *flagp; | |
88 | { | |
89 | char_u *sname; | |
90 | + char_u *p; | |
91 | int retval = OK; | |
92 | ||
93 | sname = home_replace_save(NULL, name); | |
94 | ! if (sname == NULL) | |
95 | ! return FAIL; | |
96 | ||
97 | ! if (*flagp & SSOP_SLASH) | |
98 | ! { | |
99 | ! /* change all backslashes to forward slashes */ | |
100 | ! for (p = sname; *p != NUL; mb_ptr_adv(p)) | |
101 | ! if (*p == '\\') | |
102 | ! *p = '/'; | |
103 | } | |
104 | + | |
105 | + /* escapse special characters */ | |
106 | + p = vim_strsave_fnameescape(sname, FALSE); | |
107 | vim_free(sname); | |
108 | + if (p == NULL) | |
109 | + return FAIL; | |
110 | + | |
111 | + /* write the result */ | |
112 | + if (fputs((char *)p, fd) < 0) | |
113 | + retval = FAIL; | |
114 | + | |
115 | + vim_free(p); | |
116 | return retval; | |
117 | } | |
118 | ||
119 | *** ../vim-7.3.024/src/version.c 2010-10-13 16:44:17.000000000 +0200 | |
120 | --- src/version.c 2010-10-13 17:49:15.000000000 +0200 | |
121 | *************** | |
122 | *** 716,717 **** | |
123 | --- 716,719 ---- | |
124 | { /* Add new patch number below this line */ | |
125 | + /**/ | |
126 | + 25, | |
127 | /**/ | |
128 | ||
129 | -- | |
130 | "Time flies like an arrow". So I put an arrow on my desk, now | |
131 | awaiting one of these time flies showing up. | |
132 | ||
133 | /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ | |
134 | /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ | |
135 | \\\ download, build and distribute -- http://www.A-A-P.org /// | |
136 | \\\ help me help AIDS victims -- http://ICCF-Holland.org /// |