kernel32: Fix improper escaping of quotes in command line.
Signed-off-by: Jacob Lifshay <programmerjake@gmail.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
f353e42561
commit
c7ad47e9b2
|
@ -745,6 +745,10 @@ static void update_library_argv0( const WCHAR *argv0 )
|
||||||
* resulting in an odd number of '\' followed by a '"'
|
* resulting in an odd number of '\' followed by a '"'
|
||||||
* '\"' -> '\\\"'
|
* '\"' -> '\\\"'
|
||||||
* '\\"' -> '\\\\\"'
|
* '\\"' -> '\\\\\"'
|
||||||
|
* - '\'s are followed by the closing '"' must be doubled,
|
||||||
|
* resulting in an even number of '\' followed by a '"'
|
||||||
|
* ' \' -> '" \\"'
|
||||||
|
* ' \\' -> '" \\\\"'
|
||||||
* - '\'s that are not followed by a '"' can be left as is
|
* - '\'s that are not followed by a '"' can be left as is
|
||||||
* 'a\b' == 'a\b'
|
* 'a\b' == 'a\b'
|
||||||
* 'a\\b' == 'a\\b'
|
* 'a\\b' == 'a\\b'
|
||||||
|
@ -787,7 +791,7 @@ static BOOL build_command_line( WCHAR **argv )
|
||||||
}
|
}
|
||||||
len+=(a-*arg)+1 /* for the separating space */;
|
len+=(a-*arg)+1 /* for the separating space */;
|
||||||
if (has_space)
|
if (has_space)
|
||||||
len+=2; /* for the quotes */
|
len+=2+bcount; /* for the quotes and doubling of '\' preceding the closing quote */
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(rupp->CommandLine.Buffer = RtlAllocateHeap( GetProcessHeap(), 0, len * sizeof(WCHAR))))
|
if (!(rupp->CommandLine.Buffer = RtlAllocateHeap( GetProcessHeap(), 0, len * sizeof(WCHAR))))
|
||||||
|
@ -800,6 +804,7 @@ static BOOL build_command_line( WCHAR **argv )
|
||||||
{
|
{
|
||||||
BOOL has_space,has_quote;
|
BOOL has_space,has_quote;
|
||||||
WCHAR* a;
|
WCHAR* a;
|
||||||
|
int bcount;
|
||||||
|
|
||||||
/* Check for quotes and spaces in this argument */
|
/* Check for quotes and spaces in this argument */
|
||||||
has_space=has_quote=FALSE;
|
has_space=has_quote=FALSE;
|
||||||
|
@ -821,9 +826,7 @@ static BOOL build_command_line( WCHAR **argv )
|
||||||
/* Now transfer it to the command line */
|
/* Now transfer it to the command line */
|
||||||
if (has_space)
|
if (has_space)
|
||||||
*p++='"';
|
*p++='"';
|
||||||
if (has_quote) {
|
if (has_quote || has_space) {
|
||||||
int bcount;
|
|
||||||
|
|
||||||
bcount=0;
|
bcount=0;
|
||||||
a=*arg;
|
a=*arg;
|
||||||
while (*a!='\0') {
|
while (*a!='\0') {
|
||||||
|
@ -849,8 +852,14 @@ static BOOL build_command_line( WCHAR **argv )
|
||||||
WCHAR* x = *arg;
|
WCHAR* x = *arg;
|
||||||
while ((*p=*x++)) p++;
|
while ((*p=*x++)) p++;
|
||||||
}
|
}
|
||||||
if (has_space)
|
if (has_space) {
|
||||||
|
int i;
|
||||||
|
|
||||||
|
/* Double all the '\' preceding the closing quote */
|
||||||
|
for (i=0;i<bcount;i++)
|
||||||
|
*p++='\\';
|
||||||
*p++='"';
|
*p++='"';
|
||||||
|
}
|
||||||
*p++=' ';
|
*p++=' ';
|
||||||
}
|
}
|
||||||
if (p > rupp->CommandLine.Buffer)
|
if (p > rupp->CommandLine.Buffer)
|
||||||
|
|
Loading…
Reference in New Issue