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

This commit is contained in:
Mike McCormack 2006-08-09 20:38:51 +09:00 committed by Alexandre Julliard
parent 1cc186ba81
commit 4fa9f63761
2 changed files with 39 additions and 1 deletions

View File

@ -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;
}

View File

@ -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));