shell32: remove unneeded parsing of SHELLEXECUTEINFO.lpFile [try 3]
Ilya Basin
basinilya at gmail.com
Sat Apr 24 03:53:24 CDT 2010
1) removes the block of code that splits lpFile into filename and
parameters and removes '"'s from filename . Even without this block
ShellExecute not fails with quoted lpFile.
2) removes 2 corresponding todo_wine's from tests.
The real application affected by this bug is uTorrent: if you have 2
downloads containing, say,
"foo/bar.avi" and "foo 2/baz.avi", when you double click the latter
avi file, it'll open the explorer in folder "foo" instead.
try 2:
disabled todo_wine for "%s\\masked file.shlexec"
instead of disabling all todo_wine's in the loop
try 3:
try 2 didn't apply cleanly in git: ok() format string changed.
---
dlls/shell32/shlexec.c | 62 +-----------------------------------------
dlls/shell32/tests/shlexec.c | 16 +++++------
2 files changed, 8 insertions(+), 70 deletions(-)
diff --git a/dlls/shell32/shlexec.c b/dlls/shell32/shlexec.c
index a81cada..b89bb08 100644
--- a/dlls/shell32/shlexec.c
+++ b/dlls/shell32/shlexec.c
@@ -1678,67 +1678,7 @@ static BOOL SHELL_execute( LPSHELLEXECUTEINFOW sei, SHELL_ExecuteW32 execfunc )
/* Else, try to execute the filename */
TRACE("execute:%s,%s,%s\n", debugstr_w(wszApplicationName), debugstr_w(wszParameters), debugstr_w(wszDir));
- /* separate out command line arguments from executable file name */
- if (!*sei_tmp.lpParameters && !appKnownSingular) {
- /* If the executable path is quoted, handle the rest of the command line as parameters. */
- if (sei_tmp.lpFile[0] == '"') {
- LPWSTR src = wszApplicationName/*sei_tmp.lpFile*/ + 1;
- LPWSTR dst = wfileName;
- LPWSTR end;
-
- /* copy the unquoted executable path to 'wfileName' */
- while(*src && *src!='"')
- *dst++ = *src++;
-
- *dst = '\0';
-
- if (*src == '"') {
- end = ++src;
-
- while(isspace(*src))
- ++src;
- } else
- end = src;
-
- /* copy the parameter string to 'wszParameters' */
- strcpyW(wszParameters, src);
-
- /* terminate previous command string after the quote character */
- *end = '\0';
- }
- else
- {
- /* If the executable name is not quoted, we have to use this search loop here,
- that in CreateProcess() is not sufficient because it does not handle shell links. */
- WCHAR buffer[MAX_PATH], xlpFile[MAX_PATH];
- LPWSTR space, s;
-
- LPWSTR beg = wszApplicationName/*sei_tmp.lpFile*/;
- for(s=beg; (space=strchrW(s, ' ')); s=space+1) {
- int idx = space-sei_tmp.lpFile;
- memcpy(buffer, sei_tmp.lpFile, idx * sizeof(WCHAR));
- buffer[idx] = '\0';
-
- /*FIXME This finds directory paths if the targeted file name contains spaces. */
- if (SearchPathW(*sei_tmp.lpDirectory? sei_tmp.lpDirectory: NULL, buffer, wszExe, sizeof(xlpFile)/sizeof(xlpFile[0]), xlpFile, NULL))
- {
- /* separate out command from parameter string */
- LPCWSTR p = space + 1;
-
- while(isspaceW(*p))
- ++p;
-
- strcpyW(wszParameters, p);
- *space = '\0';
-
- break;
- }
- }
-
- lstrcpynW(wfileName, sei_tmp.lpFile,sizeof(wfileName)/sizeof(WCHAR));
- }
- } else
- lstrcpynW(wfileName, sei_tmp.lpFile,sizeof(wfileName)/sizeof(WCHAR));
+ lstrcpynW(wfileName, sei_tmp.lpFile,sizeof(wfileName)/sizeof(WCHAR));
lpFile = wfileName;
diff --git a/dlls/shell32/tests/shlexec.c b/dlls/shell32/tests/shlexec.c
index ffdf393..d98db2b 100644
--- a/dlls/shell32/tests/shlexec.c
+++ b/dlls/shell32/tests/shlexec.c
@@ -839,7 +839,7 @@ static filename_tests_t filename_tests[]=
{"QuotedUpperL", "%s\\test file.shlexec", 0x0, 33},
/* Test file masked due to space */
- {NULL, "%s\\masked file.shlexec", 0x1, 33},
+ {NULL, "%s\\masked file.shlexec", 0x0, 33},
/* Test if quoting prevents the masking */
{NULL, "%s\\masked file.shlexec", 0x40, 33},
@@ -872,18 +872,16 @@ static void test_lpFile_parsed(void)
/* ensure tmpdir is in %TEMP%: GetTempPath() can succeed even if TEMP is undefined */
SetEnvironmentVariableA("TEMP", fileA);
- /* existing "drawback_file.noassoc" prevents finding "drawback_file.noassoc foo.shlexec" on wine */
+ /* existing "drawback_file.noassoc" not prevents finding "drawback_file.noassoc foo.shlexec" */
testfile = "%s\\drawback_file.noassoc foo.shlexec";
sprintf(fileA, testfile, tmpdir);
rc=shell_execute(NULL, fileA, NULL, NULL);
- todo_wine {
- ok(rc>32,
- "expected success (33), got %s (%d), lpFile: %s\n",
- rc > 32 ? "success" : "failure", rc, fileA
- );
- }
+ ok(rc>32,
+ "expected success (33), got %s (%d), lpFile: %s\n",
+ rc > 32 ? "success" : "failure", rc, fileA
+ );
- /* if quoted, existing "drawback_file.noassoc" not prevents finding "drawback_file.noassoc foo.shlexec" on wine */
+ /* if quoted, existing "drawback_file.noassoc" not prevents finding "drawback_file.noassoc foo.shlexec" */
testfile = "\"%s\\drawback_file.noassoc foo.shlexec\"";
sprintf(fileA, testfile, tmpdir);
rc=shell_execute(NULL, fileA, NULL, NULL);
--
1.7.0.2
More information about the wine-patches
mailing list