hlink: Improve file protocol handling in HlinkParseDisplayName.

This commit is contained in:
Piotr Caban 2014-03-04 16:53:05 +01:00 committed by Alexandre Julliard
parent 595fb40efc
commit 049f08f4cd
2 changed files with 38 additions and 8 deletions

View File

@ -380,6 +380,8 @@ HRESULT WINAPI HlinkUpdateStackItem(IHlinkFrame *frame, IHlinkBrowseContext *bc,
HRESULT WINAPI HlinkParseDisplayName(LPBC pibc, LPCWSTR pwzDisplayName, BOOL fNoForceAbs, HRESULT WINAPI HlinkParseDisplayName(LPBC pibc, LPCWSTR pwzDisplayName, BOOL fNoForceAbs,
ULONG *pcchEaten, IMoniker **ppimk) ULONG *pcchEaten, IMoniker **ppimk)
{ {
static const WCHAR file_colonW[] = {'f','i','l','e',':'};
ULONG eaten = 0;
HRESULT hres; HRESULT hres;
TRACE("(%p %s %x %p %p)\n", pibc, debugstr_w(pwzDisplayName), fNoForceAbs, pcchEaten, ppimk); TRACE("(%p %s %x %p %p)\n", pibc, debugstr_w(pwzDisplayName), fNoForceAbs, pcchEaten, ppimk);
@ -387,17 +389,27 @@ HRESULT WINAPI HlinkParseDisplayName(LPBC pibc, LPCWSTR pwzDisplayName, BOOL fNo
if(fNoForceAbs) if(fNoForceAbs)
FIXME("Unsupported fNoForceAbs\n"); FIXME("Unsupported fNoForceAbs\n");
hres = MkParseDisplayNameEx(pibc, pwzDisplayName, pcchEaten, ppimk); if(!strncmpiW(pwzDisplayName, file_colonW, sizeof(file_colonW)/sizeof(WCHAR))) {
if(SUCCEEDED(hres)) pwzDisplayName += sizeof(file_colonW)/sizeof(WCHAR);
return hres; eaten += sizeof(file_colonW)/sizeof(WCHAR);
hres = MkParseDisplayName(pibc, pwzDisplayName, pcchEaten, ppimk); while(*pwzDisplayName == '/') {
if(SUCCEEDED(hres)) pwzDisplayName++;
return hres; eaten++;
}
}else {
hres = MkParseDisplayNameEx(pibc, pwzDisplayName, pcchEaten, ppimk);
if(SUCCEEDED(hres))
return hres;
hres = MkParseDisplayName(pibc, pwzDisplayName, pcchEaten, ppimk);
if(SUCCEEDED(hres))
return hres;
}
hres = CreateFileMoniker(pwzDisplayName, ppimk); hres = CreateFileMoniker(pwzDisplayName, ppimk);
if(SUCCEEDED(hres)) if(SUCCEEDED(hres))
*pcchEaten = strlenW(pwzDisplayName); *pcchEaten = eaten + strlenW(pwzDisplayName);
return hres; return hres;
} }

View File

@ -626,6 +626,8 @@ static void test_HlinkParseDisplayName(void)
static const WCHAR clsid_nameW[] = {'c','l','s','i','d',':', static const WCHAR clsid_nameW[] = {'c','l','s','i','d',':',
'2','0','D','0','4','F','E','0','-','3','A','E','A','-','1','0','6','9','-','A','2','D','8', '2','0','D','0','4','F','E','0','-','3','A','E','A','-','1','0','6','9','-','A','2','D','8',
'-','0','8','0','0','2','B','3','0','3','0','9','D',':',0}; '-','0','8','0','0','2','B','3','0','3','0','9','D',':',0};
static const WCHAR file_urlW[] =
{'f','i','l','e',':','/','/','/','c',':','\\','f','i','l','e','.','t','x','t',0};
CreateBindCtx(0, &bctx); CreateBindCtx(0, &bctx);
@ -657,7 +659,7 @@ static void test_HlinkParseDisplayName(void)
IMoniker_Release(mon); IMoniker_Release(mon);
hres = HlinkParseDisplayName(bctx, invalid_urlW, FALSE, &eaten, &mon); hres = HlinkParseDisplayName(bctx, invalid_urlW, FALSE, &eaten, &mon);
ok(hres == S_OK, "HlinkParseDisplayName failed: %08x\n", hres); ok(hres == S_OK, "HlinkParseDisplayName failed: %08x\n", hres);
ok(eaten == sizeof(invalid_urlW)/sizeof(WCHAR)-1, "eaten=%d\n", eaten); ok(eaten == sizeof(invalid_urlW)/sizeof(WCHAR)-1, "eaten=%d\n", eaten);
ok(mon != NULL, "mon == NULL\n"); ok(mon != NULL, "mon == NULL\n");
@ -670,6 +672,22 @@ static void test_HlinkParseDisplayName(void)
ok(hres == S_OK, "IsSystemMoniker failed: %08x\n", hres); ok(hres == S_OK, "IsSystemMoniker failed: %08x\n", hres);
ok(issys == MKSYS_FILEMONIKER, "issys=%x\n", issys); ok(issys == MKSYS_FILEMONIKER, "issys=%x\n", issys);
IMoniker_Release(mon);
hres = HlinkParseDisplayName(bctx, file_urlW, FALSE, &eaten, &mon);
ok(hres == S_OK, "HlinkParseDisplayName failed: %08x\n", hres);
ok(eaten == sizeof(file_urlW)/sizeof(WCHAR)-1, "eaten=%d\n", eaten);
ok(mon != NULL, "mon == NULL\n");
hres = IMoniker_GetDisplayName(mon, bctx, 0, &name);
ok(hres == S_OK, "GetDiasplayName failed: %08x\n", hres);
ok(!lstrcmpW(name, file_urlW+8), "wrong display name %s\n", wine_dbgstr_w(name));
CoTaskMemFree(name);
hres = IMoniker_IsSystemMoniker(mon, &issys);
ok(hres == S_OK, "IsSystemMoniker failed: %08x\n", hres);
ok(issys == MKSYS_FILEMONIKER, "issys=%x\n", issys);
IMoniker_Release(mon); IMoniker_Release(mon);
IBindCtx_Release(bctx); IBindCtx_Release(bctx);
} }