Commit 4fa9f637 authored by Mike McCormack's avatar Mike McCormack Committed by Alexandre Julliard

shell32: IShellLink::SetPath removes quotes from the path.

parent 1cc186ba
......@@ -2156,11 +2156,25 @@ static HRESULT WINAPI IShellLinkW_fnSetPath(IShellLinkW * iface, LPCWSTR pszFile
{
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_fnSetPath(IShellLinkW * iface, LPCWSTR pszFile
lstrcpyW(This->sPath, buffer);
}
This->bDirty = TRUE;
HeapFree(GetProcessHeap(), 0, unquoted);
return hr;
}
......
......@@ -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));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment