Patch 8.0.1176
Problem:    Job_start() does not handle quote and backslash correctly.
Solution:   Remove quotes, recognize and remove backslashes.
Files:      src/testdir/test_channel.vim, src/os_unix.c


*** ../vim-8.0.1175/src/testdir/test_channel.vim        2017-08-13 
17:13:03.013546322 +0200
--- src/testdir/test_channel.vim        2017-10-06 00:58:47.587225329 +0200
***************
*** 1590,1595 ****
--- 1590,1611 ----
    bwipe!
  endfunc
  
+ func Test_cmd_parsing()
+   if !has('unix')
+     return
+   endif
+   call assert_false(filereadable("file with space"))
+   let job = job_start('touch "file with space"')
+   call WaitFor('filereadable("file with space")')
+   call assert_true(filereadable("file with space"))
+   call delete("file with space")
+ 
+   let job = job_start('touch file\ with\ space')
+   call WaitFor('filereadable("file with space")')
+   call assert_true(filereadable("file with space"))
+   call delete("file with space")
+ endfunc
+ 
  func Test_raw_passes_nul()
    if !executable('cat') || !has('job')
      return
*** ../vim-8.0.1175/src/os_unix.c       2017-10-01 16:21:25.297497445 +0200
--- src/os_unix.c       2017-10-06 00:53:23.804993343 +0200
***************
*** 4074,4080 ****
  mch_parse_cmd(char_u *cmd, int use_shcf, char ***argv, int *argc)
  {
      int               i;
!     char_u    *p;
      int               inquote;
  
      /*
--- 4074,4080 ----
  mch_parse_cmd(char_u *cmd, int use_shcf, char ***argv, int *argc)
  {
      int               i;
!     char_u    *p, *d;
      int               inquote;
  
      /*
***************
*** 4092,4117 ****
            if (i == 1)
                (*argv)[*argc] = (char *)p;
            ++*argc;
            while (*p != NUL && (inquote || (*p != ' ' && *p != TAB)))
            {
                if (p[0] == '"')
                    inquote = !inquote;
!               else if (p[0] == '\\' && p[1] != NUL)
                {
!                   /* First pass: skip over "\ " and "\"".
!                    * Second pass: Remove the backslash. */
!                   if (i == 1)
!                       mch_memmove(p, p + 1, STRLEN(p));
!                   else
                        ++p;
                }
                ++p;
            }
            if (*p == NUL)
                break;
            if (i == 1)
!               *p++ = NUL;
!           p = skipwhite(p);
        }
        if (*argv == NULL)
        {
--- 4092,4125 ----
            if (i == 1)
                (*argv)[*argc] = (char *)p;
            ++*argc;
+           d = p;
            while (*p != NUL && (inquote || (*p != ' ' && *p != TAB)))
            {
                if (p[0] == '"')
+                   /* quotes surrounding an argument and are dropped */
                    inquote = !inquote;
!               else
                {
!                   if (p[0] == '\\' && p[1] != NUL)
!                   {
!                       /* First pass: skip over "\ " and "\"".
!                        * Second pass: Remove the backslash. */
                        ++p;
+                   }
+                   if (i == 1)
+                       *d++ = *p;
                }
                ++p;
            }
            if (*p == NUL)
+           {
+               if (i == 1)
+                   *d++ = NUL;
                break;
+           }
            if (i == 1)
!               *d++ = NUL;
!           p = skipwhite(p + 1);
        }
        if (*argv == NULL)
        {
*** ../vim-8.0.1175/src/version.c       2017-10-04 19:34:58.175740352 +0200
--- src/version.c       2017-10-05 18:31:28.290865619 +0200
***************
*** 763,764 ****
--- 763,766 ----
  {   /* Add new patch number below this line */
+ /**/
+     1176,
  /**/

-- 
hundred-and-one symptoms of being an internet addict:
270. You are subscribed to a mailing list for every piece of software
     you use.

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
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

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Raspunde prin e-mail lui