PATCH: escape \ in shell link
Marcus Meissner
meissner at suse.de
Wed Oct 30 05:32:25 CST 2002
Hi,
KDE hat path entries like:
Path=wine "c:\Lotus\Notes\notes.exe" --
KDE tried to execute
wine "c:\Lotus\Notes
otes.exe" --
evaluating the backslashes as shell escapes.
This patch just doubles the number of escapes. The same
goes for the arguments.
Ciao, Marcus
Changelog:
Escape \ in path and arguments.
Use UNIX style work_dir, not windows dir.
Index: dlls/shell32/shelllink.c
===================================================================
RCS file: /home/wine/wine/dlls/shell32/shelllink.c,v
retrieving revision 1.46
diff -u -r1.46 shelllink.c
--- dlls/shell32/shelllink.c 20 Aug 2002 00:25:03 -0000 1.46
+++ dlls/shell32/shelllink.c 30 Oct 2002 11:28:54 -0000
@@ -581,6 +581,22 @@
return NULL;
}
+/* This escapes \ in filenames */
+static LPSTR
+escape(LPCSTR arg) {
+ LPSTR narg, x;
+
+ narg = HeapAlloc(GetProcessHeap(),0,2*strlen(arg)+2);
+ x = narg;
+ while (*arg) {
+ *x++ = *arg;
+ if (*arg == '\\')
+ *x++='\\'; /* escape \ */
+ arg++;
+ }
+ *x = 0;
+ return narg;
+}
static HRESULT WINAPI IPersistFile_fnSave(IPersistFile* iface, LPCOLESTR pszFileName, BOOL fRemember)
{
@@ -591,6 +607,8 @@
char *shell_link_app = NULL;
char *icon_name = NULL;
char *work_dir = NULL;
+ char *escaped_path = NULL;
+ char *escaped_args = NULL;
BOOL bDesktop;
HKEY hkey;
@@ -698,6 +716,11 @@
This->sDescription ? This->sDescription : "" );
if ((pid = fork()) == -1) goto done;
+
+ escaped_path = escape(This->sPath);
+ if (This->sArgs)
+ escaped_args = escape(This->sArgs);
+
if (!pid)
{
int pos = 0;
@@ -706,12 +729,12 @@
argv[pos++] = "--link";
argv[pos++] = link_name;
argv[pos++] = "--path";
- argv[pos++] = This->sPath;
+ argv[pos++] = escaped_path;
argv[pos++] = bDesktop ? "--desktop" : "--menu";
if (This->sArgs && strlen(This->sArgs))
{
argv[pos++] = "--args";
- argv[pos++] = This->sArgs;
+ argv[pos++] = escaped_args;
}
if (icon_name)
{
@@ -721,7 +744,7 @@
if (This->sWorkDir && strlen(This->sWorkDir))
{
argv[pos++] = "--workdir";
- argv[pos++] = This->sWorkDir;
+ argv[pos++] = work_dir;
}
if (This->sDescription && strlen(This->sDescription))
{
@@ -749,6 +772,8 @@
HeapFree( GetProcessHeap(), 0, filename );
HeapFree( GetProcessHeap(), 0, icon_name );
HeapFree( GetProcessHeap(), 0, work_dir );
+ if (escaped_args) HeapFree( GetProcessHeap(), 0, escaped_args );
+ if (escaped_path) HeapFree( GetProcessHeap(), 0, escaped_path );
return ret;
}
More information about the wine-patches
mailing list