Fix ShellExecute("\"foo.doc\"")

Francois Gouget fgouget at codeweavers.com
Wed Aug 17 01:58:46 CDT 2005


IE 6 passes a quoted path to ShellExecute() which the conformance tests 
show is supported by recent versions of the shell32 dll. So this patch 
fixes this case and updates the conformance test accordingly.

Changelog:

  * dlls/shell32/shlexec.c
    dlls/shell32/tests/shlexec.c

    Francois Gouget <fgouget at codeweavers.com>
    Fix ShellExecute("\"foo.doc\"") for Internet Explorer 6.
    Update the conformance tests accordingly.
    Tweak a trace because it's very confusing to see the path with no 
escaped quotes in ShellExecuteA() and then with escaped quotes in 
ShellExecuteExW32() (due to debugstr_w()).

-- 
Francois Gouget
fgouget at codeweavers.com

-------------- next part --------------
Index: dlls/shell32/shlexec.c
===================================================================
RCS file: /var/cvs/wine/dlls/shell32/shlexec.c,v
retrieving revision 1.68
diff -u -p -r1.68 shlexec.c
--- dlls/shell32/shlexec.c	11 Aug 2005 17:04:31 -0000	1.68
+++ dlls/shell32/shlexec.c	17 Aug 2005 06:32:03 -0000
@@ -1008,10 +1008,19 @@ BOOL WINAPI ShellExecuteExW32 (LPSHELLEX
     sei->hProcess = NULL;
 
     /* make copies of all path/command strings */
-    if (sei_tmp.lpFile)
-	strcpyW(wszApplicationName, sei_tmp.lpFile);
+    if (!sei_tmp.lpFile)
+        *wszApplicationName = '\0';
+    else if (*sei_tmp.lpFile == '\"')
+    {
+        UINT l;
+        strcpyW(wszApplicationName, sei_tmp.lpFile+1);
+        l=lstrlenW(wszApplicationName);
+        if (wszApplicationName[l-1] == '\"')
+            wszApplicationName[l-1] = '\0';
+        TRACE("wszApplicationName=%s\n",debugstr_w(wszApplicationName));
+    }
     else
-	*wszApplicationName = '\0';
+        strcpyW(wszApplicationName, sei_tmp.lpFile);
 
     if (sei_tmp.lpParameters)
 	strcpyW(wszParameters, sei_tmp.lpParameters);
@@ -1353,7 +1362,8 @@ HINSTANCE WINAPI ShellExecuteA(HWND hWnd
     HANDLE hProcess = 0;
 
     TRACE("%p,%s,%s,%s,%s,%d\n",
-           hWnd, lpOperation, lpFile, lpParameters, lpDirectory, iShowCmd);
+          hWnd, debugstr_a(lpOperation), debugstr_a(lpFile),
+          debugstr_a(lpParameters), debugstr_a(lpDirectory), iShowCmd);
 
     sei.cbSize = sizeof(sei);
     sei.fMask = 0;
Index: dlls/shell32/tests/shlexec.c
===================================================================
RCS file: /var/cvs/wine/dlls/shell32/tests/shlexec.c,v
retrieving revision 1.2
diff -u -p -r1.2 shlexec.c
--- dlls/shell32/tests/shlexec.c	16 Aug 2005 19:29:27 -0000	1.2
+++ dlls/shell32/tests/shlexec.c	17 Aug 2005 06:32:48 -0000
@@ -577,14 +577,10 @@ static void test_filename()
         rc=shell_execute(NULL, filename, NULL, NULL);
         ok(rc>=32, "%s failed: rc=%d err=%ld\n", shell_call, rc,
            GetLastError());
-        todo_wine {
         okChildInt("argcA", 5);
-        }
         okChildString("argvA3", "Open");
         sprintf(filename, "%s\\test file.shlexec", tmpdir);
-        todo_wine {
         okChildPath("argvA4", filename);
-        }
     }
 }
 


More information about the wine-patches mailing list