mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 18:15:11 +00:00
[SHELL32] shlexec: Simplify parameters parsing (#7207)
Simplify code logic. JIRA issue: N/A - Use PathGetArgsW, PathRemoveArgsW, and PathUnquoteSpacesW for parsing parameters.
This commit is contained in:
parent
deccfb8c9f
commit
266e2e5052
1 changed files with 12 additions and 32 deletions
|
@ -2153,39 +2153,26 @@ static BOOL SHELL_execute(LPSHELLEXECUTEINFOW sei, SHELL_ExecuteW32 execfunc)
|
||||||
TRACE("execute: %s,%s,%s\n", debugstr_w(wszApplicationName), debugstr_w(wszParameters), debugstr_w(wszDir));
|
TRACE("execute: %s,%s,%s\n", debugstr_w(wszApplicationName), debugstr_w(wszParameters), debugstr_w(wszDir));
|
||||||
|
|
||||||
/* separate out command line arguments from executable file name */
|
/* separate out command line arguments from executable file name */
|
||||||
LPCWSTR lpFile;
|
LPCWSTR lpFile = sei_tmp.lpFile;
|
||||||
WCHAR wfileName[MAX_PATH];
|
|
||||||
if (!*sei_tmp.lpParameters && !appKnownSingular)
|
if (!*sei_tmp.lpParameters && !appKnownSingular)
|
||||||
{
|
{
|
||||||
/* If the executable path is quoted, handle the rest of the command line as parameters. */
|
/* If the executable path is quoted, handle the rest of the command line as parameters. */
|
||||||
if (sei_tmp.lpFile[0] == L'"')
|
if (sei_tmp.lpFile[0] == L'"')
|
||||||
{
|
{
|
||||||
LPWSTR src = wszApplicationName/*sei_tmp.lpFile*/ + 1;
|
LPWSTR pszArgs = PathGetArgsW(wszApplicationName);
|
||||||
LPWSTR dst = wfileName;
|
PathRemoveArgsW(wszApplicationName);
|
||||||
LPWSTR end;
|
PathUnquoteSpacesW(wszApplicationName);
|
||||||
|
parametersLen = lstrlenW(pszArgs);
|
||||||
/* copy the unquoted executable path to 'wfileName' */
|
if (parametersLen < _countof(parametersBuffer))
|
||||||
while(*src && *src != L'"')
|
|
||||||
*dst++ = *src++;
|
|
||||||
|
|
||||||
*dst = L'\0';
|
|
||||||
|
|
||||||
if (*src == L'"')
|
|
||||||
{
|
{
|
||||||
end = ++src;
|
StringCchCopyW(parametersBuffer, _countof(parametersBuffer), pszArgs);
|
||||||
|
wszParameters = parametersBuffer;
|
||||||
while(isspaceW(*src))
|
|
||||||
++src;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
end = src;
|
{
|
||||||
|
wszParamAlloc.Attach(StrDupW(pszArgs));
|
||||||
/* copy the parameter string to 'wszParameters' */
|
wszParameters = wszParamAlloc;
|
||||||
strcpyW(wszParameters, src);
|
}
|
||||||
|
|
||||||
/* terminate previous command string after the quote character */
|
|
||||||
*end = L'\0';
|
|
||||||
lpFile = wfileName;
|
|
||||||
}
|
}
|
||||||
/* We have to test sei instead of sei_tmp because sei_tmp had its
|
/* We have to test sei instead of sei_tmp because sei_tmp had its
|
||||||
* input fMask modified above in SHELL_translate_idlist.
|
* input fMask modified above in SHELL_translate_idlist.
|
||||||
|
@ -2218,15 +2205,8 @@ static BOOL SHELL_execute(LPSHELLEXECUTEINFOW sei, SHELL_ExecuteW32 execfunc)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
lpFile = sei_tmp.lpFile;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
lpFile = sei_tmp.lpFile;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
lpFile = sei_tmp.lpFile;
|
|
||||||
|
|
||||||
WCHAR wcmdBuffer[1024];
|
WCHAR wcmdBuffer[1024];
|
||||||
LPWSTR wcmd = wcmdBuffer;
|
LPWSTR wcmd = wcmdBuffer;
|
||||||
|
|
Loading…
Reference in a new issue