cmd: Handle quotes when parsing the folders in the PATH environment variable.
Semicolons are also allowed inside a path, as long as they are quoted. Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=45552 Signed-off-by: Fabian Maurer <dark.shadow4@web.de> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
bdca749f7b
commit
d175419f0b
|
@ -507,6 +507,23 @@ rem Only the final quote ends the string
|
||||||
set "WINE_FOO=apple"banana"grape"orange
|
set "WINE_FOO=apple"banana"grape"orange
|
||||||
echo '%WINE_FOO%'
|
echo '%WINE_FOO%'
|
||||||
set WINE_FOO=
|
set WINE_FOO=
|
||||||
|
rem set PATH must work with quotes
|
||||||
|
set PATH_BACKUP=%PATH%
|
||||||
|
mkdir folder
|
||||||
|
mkdir "fol;der"
|
||||||
|
echo echo I'm here! > "fol;der\sub1.bat"
|
||||||
|
echo echo I'm here! > folder\sub1.bat
|
||||||
|
set PATH=nothing;"fol;der"
|
||||||
|
call sub1
|
||||||
|
set PATH="folder
|
||||||
|
call sub1
|
||||||
|
set PATH=folder"
|
||||||
|
call sub1
|
||||||
|
del "fol;der\sub1.bat"
|
||||||
|
del folder\sub1.bat
|
||||||
|
rmdir "fol;der"
|
||||||
|
rmdir folder
|
||||||
|
PATH=%PATH_BACKUP%
|
||||||
|
|
||||||
echo ------------ Testing variable expansion ------------
|
echo ------------ Testing variable expansion ------------
|
||||||
call :setError 0
|
call :setError 0
|
||||||
|
|
|
@ -475,6 +475,9 @@ foo
|
||||||
'jim fred'
|
'jim fred'
|
||||||
'jim'
|
'jim'
|
||||||
'apple"banana"grape'
|
'apple"banana"grape'
|
||||||
|
I'm here!@space@
|
||||||
|
I'm here!@space@
|
||||||
|
I'm here!@space@
|
||||||
------------ Testing variable expansion ------------
|
------------ Testing variable expansion ------------
|
||||||
~p0 should be path containing batch file
|
~p0 should be path containing batch file
|
||||||
@path@
|
@path@
|
||||||
|
|
|
@ -1099,24 +1099,41 @@ void WCMD_run_program (WCHAR *command, BOOL called)
|
||||||
wine_dbgstr_w(stemofsearch));
|
wine_dbgstr_w(stemofsearch));
|
||||||
while (pathposn) {
|
while (pathposn) {
|
||||||
WCHAR thisDir[MAX_PATH] = {'\0'};
|
WCHAR thisDir[MAX_PATH] = {'\0'};
|
||||||
|
int length = 0;
|
||||||
WCHAR *pos = NULL;
|
WCHAR *pos = NULL;
|
||||||
BOOL found = FALSE;
|
BOOL found = FALSE;
|
||||||
|
BOOL inside_quotes = FALSE;
|
||||||
|
|
||||||
/* Work on the first directory on the search path */
|
/* Work on the first directory on the search path */
|
||||||
pos = strchrW(pathposn, ';');
|
pos = pathposn;
|
||||||
if (pos) {
|
while ((inside_quotes || *pos != ';') && *pos != 0)
|
||||||
|
{
|
||||||
|
if (*pos == '"')
|
||||||
|
inside_quotes = !inside_quotes;
|
||||||
|
pos++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (*pos) { /* Reached semicolon */
|
||||||
memcpy(thisDir, pathposn, (pos-pathposn) * sizeof(WCHAR));
|
memcpy(thisDir, pathposn, (pos-pathposn) * sizeof(WCHAR));
|
||||||
thisDir[(pos-pathposn)] = 0x00;
|
thisDir[(pos-pathposn)] = 0x00;
|
||||||
pathposn = pos+1;
|
pathposn = pos+1;
|
||||||
|
} else { /* Reached string end */
|
||||||
} else {
|
|
||||||
strcpyW(thisDir, pathposn);
|
strcpyW(thisDir, pathposn);
|
||||||
pathposn = NULL;
|
pathposn = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Remove quotes */
|
||||||
|
length = strlenW(thisDir);
|
||||||
|
if (thisDir[length - 1] == '"')
|
||||||
|
thisDir[length - 1] = 0;
|
||||||
|
|
||||||
|
if (*thisDir != '"')
|
||||||
|
strcpyW(temp, thisDir);
|
||||||
|
else
|
||||||
|
strcpyW(temp, thisDir + 1);
|
||||||
|
|
||||||
/* Since you can have eg. ..\.. on the path, need to expand
|
/* Since you can have eg. ..\.. on the path, need to expand
|
||||||
to full information */
|
to full information */
|
||||||
strcpyW(temp, thisDir);
|
|
||||||
GetFullPathNameW(temp, MAX_PATH, thisDir, NULL);
|
GetFullPathNameW(temp, MAX_PATH, thisDir, NULL);
|
||||||
|
|
||||||
/* 1. If extension supplied, see if that file exists */
|
/* 1. If extension supplied, see if that file exists */
|
||||||
|
|
Loading…
Reference in New Issue