Commit 049f08f4 authored by Piotr Caban's avatar Piotr Caban Committed by Alexandre Julliard

hlink: Improve file protocol handling in HlinkParseDisplayName.

parent 595fb40e
......@@ -380,6 +380,8 @@ HRESULT WINAPI HlinkUpdateStackItem(IHlinkFrame *frame, IHlinkBrowseContext *bc,
HRESULT WINAPI HlinkParseDisplayName(LPBC pibc, LPCWSTR pwzDisplayName, BOOL fNoForceAbs,
ULONG *pcchEaten, IMoniker **ppimk)
{
static const WCHAR file_colonW[] = {'f','i','l','e',':'};
ULONG eaten = 0;
HRESULT hres;
TRACE("(%p %s %x %p %p)\n", pibc, debugstr_w(pwzDisplayName), fNoForceAbs, pcchEaten, ppimk);
......@@ -387,6 +389,15 @@ HRESULT WINAPI HlinkParseDisplayName(LPBC pibc, LPCWSTR pwzDisplayName, BOOL fNo
if(fNoForceAbs)
FIXME("Unsupported fNoForceAbs\n");
if(!strncmpiW(pwzDisplayName, file_colonW, sizeof(file_colonW)/sizeof(WCHAR))) {
pwzDisplayName += sizeof(file_colonW)/sizeof(WCHAR);
eaten += sizeof(file_colonW)/sizeof(WCHAR);
while(*pwzDisplayName == '/') {
pwzDisplayName++;
eaten++;
}
}else {
hres = MkParseDisplayNameEx(pibc, pwzDisplayName, pcchEaten, ppimk);
if(SUCCEEDED(hres))
return hres;
......@@ -394,10 +405,11 @@ HRESULT WINAPI HlinkParseDisplayName(LPBC pibc, LPCWSTR pwzDisplayName, BOOL fNo
hres = MkParseDisplayName(pibc, pwzDisplayName, pcchEaten, ppimk);
if(SUCCEEDED(hres))
return hres;
}
hres = CreateFileMoniker(pwzDisplayName, ppimk);
if(SUCCEEDED(hres))
*pcchEaten = strlenW(pwzDisplayName);
*pcchEaten = eaten + strlenW(pwzDisplayName);
return hres;
}
......
......@@ -626,6 +626,8 @@ static void test_HlinkParseDisplayName(void)
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',
'-','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);
......@@ -671,6 +673,22 @@ static void test_HlinkParseDisplayName(void)
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);
IBindCtx_Release(bctx);
}
......
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