On Tuesday, October 4, 2016 at 5:29:16 AM UTC+9, Bram Moolenaar wrote:
> Yasuhiro Matsumoto wrote:
> 
> > On Monday, October 3, 2016 at 7:49:20 AM UTC+9, Ozaki Kiichi wrote:
> > > 
> > > https://gist.github.com/ichizok/6e0c00daf387b32bebcc2972f0cca137
> > 
> > Bram, in this patch, you can see workaround to avoid a bug with escaping 
> > double-quote on Windows.
> > 
> > https://gist.github.com/ichizok/6e0c00daf387b32bebcc2972f0cca137#file-fix-job-channel-patch-L202-L207
> > 
> > I'm working this in separately. I'll report a description and send patch in 
> > later.
> 
> Thanks.  Escaping is tricky.  Please check a few different shells.
> Checking for Win32 might not be right when 'shell' is not cmd.exe but a
> Unix-shell-like.

No need to check shell(s) because job_start doesn't use shell to start process. 
And the problem occur only on Windows.

shellexecute() make dup for double-quote like below.

shellescape('"') => """" (This mean " and "" and " )

This is right behavior when using cmd.exe. But not right for starting process 
without cmd.exe. Below is a test program.

foo.c
------------
#include <windows.h>

int
main(int argc, char* argv[]) {
  MessageBox(0, argv[1], "foo", MB_OK);
  return 0;
}
------------

C:\>foo.exe """"

This should work because it runs on cmd.exe. But it doesn't work when starting 
process without cmd.exe. Please try following.

------------
#include <windows.h>
#include <stdio.h>

int
main(int argc, char* argv[]) {
  PROCESS_INFORMATION pi;
  STARTUPINFO si;
  ZeroMemory(&si, sizeof(STARTUPINFO));
  CreateProcess(NULL, "foo \"import sys;sys.stdout.write(""1\\n2\\n3"")\"", 
NULL, NULL, TRUE, 0, NULL, NULL, &si, &pi);
  WaitForSingleObject(pi.hProcess, INFINITE);
}
------------

You expect this to display quoted "1\n2\n3" but this display non-quoted 1\n2\n3.

http://go-gyazo.appspot.com/949aca13dc74e8c3.png

See this article. 
https://blogs.msdn.microsoft.com/twistylittlepassagesallalike/2011/04/23/everyone-quotes-command-line-arguments-the-wrong-way/

We should escape double-quote as \" instead of "" if we run without cmd.exe, so 
we MUST NOT use shellescape for this. Below is an implementation of this 
escaping.

https://gist.github.com/d47e7d3bfe5ade4be86062b565a4bfca

This change will be tested via Test_read_nonl_line.

Thanks.

- mattn

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