Mike McCormack : shell32: IShellLink::SetPath removes quotes from the
path.
Alexandre Julliard
julliard at wine.codeweavers.com
Wed Aug 9 10:37:20 CDT 2006
Module: wine
Branch: refs/heads/master
Commit: 4fa9f637615f467240ef03fea147853075bed114
URL: http://source.winehq.org/git/?p=wine.git;a=commit;h=4fa9f637615f467240ef03fea147853075bed114
Author: Mike McCormack <mike at codeweavers.com>
Date: Wed Aug 9 20:38:51 2006 +0900
shell32: IShellLink::SetPath removes quotes from the path.
---
dlls/shell32/shelllink.c | 17 ++++++++++++++++-
dlls/shell32/tests/shelllink.c | 23 +++++++++++++++++++++++
2 files changed, 39 insertions(+), 1 deletions(-)
diff --git a/dlls/shell32/shelllink.c b/dlls/shell32/shelllink.c
index 751aa2e..550f3a0 100644
--- a/dlls/shell32/shelllink.c
+++ b/dlls/shell32/shelllink.c
@@ -2156,11 +2156,25 @@ static HRESULT WINAPI IShellLinkW_fnSetP
{
IShellLinkImpl *This = impl_from_IShellLinkW(iface);
WCHAR buffer[MAX_PATH];
- LPWSTR fname;
+ LPWSTR fname, unquoted = NULL;
HRESULT hr = S_OK;
+ UINT len;
TRACE("(%p)->(path=%s)\n",This, debugstr_w(pszFile));
+ /* quotes at the ends of the string are stripped */
+ len = lstrlenW(pszFile);
+ if (pszFile[0] == '"' && pszFile[len-1] == '"')
+ {
+ unquoted = strdupW(pszFile);
+ PathUnquoteSpacesW(unquoted);
+ pszFile = unquoted;
+ }
+
+ /* any other quote marks are invalid */
+ if (strchrW(pszFile, '"'))
+ return S_FALSE;
+
HeapFree(GetProcessHeap(), 0, This->sPath);
This->sPath = NULL;
@@ -2191,6 +2205,7 @@ static HRESULT WINAPI IShellLinkW_fnSetP
lstrcpyW(This->sPath, buffer);
}
This->bDirty = TRUE;
+ HeapFree(GetProcessHeap(), 0, unquoted);
return hr;
}
diff --git a/dlls/shell32/tests/shelllink.c b/dlls/shell32/tests/shelllink.c
index a6cba36..aaf0283 100644
--- a/dlls/shell32/tests/shelllink.c
+++ b/dlls/shell32/tests/shelllink.c
@@ -216,6 +216,29 @@ static void test_get_set(void)
ok(lstrcmpi(buffer, mypath)==0, "GetPath returned '%s'\n", buffer);
}
+ /* test path with quotes */
+ r = IShellLinkA_SetPath(sl, "\"c:\\nonexistent\\file\"");
+ ok(r==S_FALSE, "SetPath failed (0x%08lx)\n", r);
+
+ r = IShellLinkA_GetPath(sl, buffer, sizeof(buffer), NULL, SLGP_RAWPATH);
+ ok(r==S_OK, "GetPath failed (0x%08lx)\n", r);
+ ok(!lstrcmp(buffer, "C:\\nonexistent\\file"), "case doesn't match\n");
+
+ r = IShellLinkA_SetPath(sl, "\"c:\\foo");
+ ok(r==S_FALSE, "SetPath failed (0x%08lx)\n", r);
+
+ r = IShellLinkA_SetPath(sl, "\"\"c:\\foo");
+ ok(r==S_FALSE, "SetPath failed (0x%08lx)\n", r);
+
+ r = IShellLinkA_SetPath(sl, "c:\\foo\"");
+ ok(r==S_FALSE, "SetPath failed (0x%08lx)\n", r);
+
+ r = IShellLinkA_SetPath(sl, "\"\"c:\\foo\"");
+ ok(r==S_FALSE, "SetPath failed (0x%08lx)\n", r);
+
+ r = IShellLinkA_SetPath(sl, "\"\"c:\\foo\"\"");
+ ok(r==S_FALSE, "SetPath failed (0x%08lx)\n", r);
+
/* Test Getting / Setting the arguments */
strcpy(buffer,"garbage");
r = IShellLinkA_GetArguments(sl, buffer, sizeof(buffer));
More information about the wine-cvs
mailing list