httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Khimenko Victor" <apache-de...@khim.sch57.msk.ru>
Subject Re: Escaping arguments and ap_call_exec
Date Wed, 23 Jun 1999 11:59:31 GMT
23-Jun-99 10:45 you wrote:

MV> Hello!

MV> I'm writing a module for apache under windows. The module should start a
MV> program and I use ap_bspawn_child to do that. My function (the second
MV> argument to ap_bspawn_child) calls ap_call_exec. r->filename is set to the
MV> name of the program I want to run, and r->args is a string containing the
MV> argument to that program. Now, the trouble is that my argument string is
MV> escaped when I receive it in the program, and spaces in the original
MV> argument string are treated as argument separators.

MV> E.g:

MV> An argument string sent as:

MV> r->args = ap_pstrcat(r->pool,
MV>                      r->args,
MV>                      "d:\\program files\\my_program.exe");
MV> Arrives as:
MV> argv[1] == d:\\program
MV> argv[2] == files\\my_program.exe

MV> If I use slashes I still have trouble with the space.
MV> If I choose to double-quote the string I end up with:
MV> argv[1] == "d:\\program
MV> argv[2] == files\\my_program.exe\"

MV> So, how am I supposed to format that string before sending it to
MV> ap_call_exec?

Just like URL but without spaces in arguments :-)) There are error in
ap_call_exec ... If someone if interested in fixing: every argument with
spaces must be surrounded by " under Win32. ap_call_exec does not do
it now (Ok, may be it's fixed in CVS) and will escape " with \ so caller
routine can not fix it as well.

P.S. If argument without spaces will be surrounded by " then most programs
(all programs created with MS VC++ [2-6]) will be fine but it's possible
to find out that redundant " via GetCommandLine() function...




Mime
View raw message