home *** CD-ROM | disk | FTP | other *** search
/ vim.ftp.fu-berlin.de / 2015-02-03.vim.ftp.fu-berlin.de.tar / vim.ftp.fu-berlin.de / patches / 7.3 / 7.3.025 < prev    next >
Encoding:
Internet Message Format  |  2012-11-20  |  3.3 KB

  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. +     /* escapse special characters */
  105. +     p = vim_strsave_fnameescape(sname, FALSE);
  106.       vim_free(sname);
  107. +     if (p == NULL)
  108. +     return FAIL;
  109. +     /* write the result */
  110. +     if (fputs((char *)p, fd) < 0)
  111. +     retval = FAIL;
  112. +     vim_free(p);
  113.       return retval;
  114.   }
  115.   
  116. *** ../vim-7.3.024/src/version.c    2010-10-13 16:44:17.000000000 +0200
  117. --- src/version.c    2010-10-13 17:49:15.000000000 +0200
  118. ***************
  119. *** 716,717 ****
  120. --- 716,719 ----
  121.   {   /* Add new patch number below this line */
  122. + /**/
  123. +     25,
  124.   /**/
  125.  
  126. -- 
  127. "Time flies like an arrow".  So I put an arrow on my desk, now
  128. awaiting one of these time flies showing up.
  129.  
  130.  /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
  131. ///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
  132. \\\        download, build and distribute -- http://www.A-A-P.org        ///
  133.  \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///
  134.