mirror of
git://source.winehq.org/git/wine.git
synced 2024-10-31 11:43:31 +00:00
itss: Added CombineUrl implementation.
This commit is contained in:
parent
c0351acd57
commit
46132ee2cd
2 changed files with 122 additions and 2 deletions
|
@ -392,10 +392,45 @@ static HRESULT WINAPI ITSProtocolInfo_CombineUrl(IInternetProtocolInfo *iface,
|
|||
DWORD cchResult, DWORD* pcchResult, DWORD dwReserved)
|
||||
{
|
||||
ITSProtocol *This = PROTINFO_THIS(iface);
|
||||
FIXME("(%p)->(%s %s %08x %p %d %p %d)\n", This, debugstr_w(pwzBaseUrl),
|
||||
LPCWSTR base_end, ptr;
|
||||
DWORD rel_len;
|
||||
|
||||
static const WCHAR separator[] = {':',':',0};
|
||||
|
||||
TRACE("(%p)->(%s %s %08x %p %d %p %d)\n", This, debugstr_w(pwzBaseUrl),
|
||||
debugstr_w(pwzRelativeUrl), dwCombineFlags, pwzResult, cchResult,
|
||||
pcchResult, dwReserved);
|
||||
return E_NOTIMPL;
|
||||
|
||||
base_end = strstrW(pwzBaseUrl, separator);
|
||||
if(!base_end)
|
||||
return 0x80041001;
|
||||
base_end += 2;
|
||||
|
||||
if(!skip_schema(pwzBaseUrl))
|
||||
return INET_E_USE_DEFAULT_PROTOCOLHANDLER;
|
||||
|
||||
if(strchrW(pwzRelativeUrl, ':'))
|
||||
return STG_E_INVALIDNAME;
|
||||
|
||||
if(pwzRelativeUrl[0] != '/') {
|
||||
ptr = strrchrW(base_end, '/');
|
||||
if(ptr)
|
||||
base_end = ptr+1;
|
||||
else
|
||||
base_end += strlenW(base_end);
|
||||
}
|
||||
|
||||
rel_len = strlenW(pwzRelativeUrl)+1;
|
||||
|
||||
*pcchResult = rel_len + (base_end-pwzBaseUrl);
|
||||
|
||||
if(*pcchResult > cchResult)
|
||||
return E_OUTOFMEMORY;
|
||||
|
||||
memcpy(pwzResult, pwzBaseUrl, (base_end-pwzBaseUrl)*sizeof(WCHAR));
|
||||
strcpyW(pwzResult + (base_end-pwzBaseUrl), pwzRelativeUrl);
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI ITSProtocolInfo_CompareUrl(IInternetProtocolInfo *iface, LPCWSTR pwzUrl1,
|
||||
|
|
|
@ -409,6 +409,67 @@ static void test_protocol_url(IClassFactory *factory, LPCWSTR url)
|
|||
read_protocol = NULL;
|
||||
}
|
||||
|
||||
static const WCHAR rel_url1[] =
|
||||
{'t','e','s','t','.','h','t','m','l',0};
|
||||
static const WCHAR rel_url2[] =
|
||||
{'t','e','s','t','.','c','h','m',':',':','/','t','e','s','t','.','h','t','m','l',0};
|
||||
static const WCHAR rel_url3[] =
|
||||
{'/','t','e','s','t','.','h','t','m','l',0};
|
||||
static const WCHAR rel_url4[] =
|
||||
{'t','e',':','t','.','h','t','m','l',0};
|
||||
static const WCHAR rel_url5[] =
|
||||
{'d','i','r','/','t','e','s','t','.','h','t','m','l',0};
|
||||
|
||||
static const WCHAR base_url1[] = {'i','t','s',':',
|
||||
't','e','s','t',':','.','c','h','m',':',':','/','b','l','a','n','k','.','h','t','m','l',0};
|
||||
static const WCHAR base_url2[] = {'i','t','s',':','t','e','s','t','.','c','h','m',
|
||||
':',':','/','d','i','r','/','b','l','a','n','k','.','h','t','m','l',0};
|
||||
static const WCHAR base_url3[] = {'m','s','-','i','t','s',':','t','e','s','t','.','c','h','m',
|
||||
':',':','/','d','i','r','/','b','l','a','n','k','.','h','t','m','l',0};
|
||||
static const WCHAR base_url4[] = {'m','k',':','@','M','S','I','T','S','t','o','r','e',':',
|
||||
't','e','s','t','.','c','h','m',':',':','/','d','i','r','/',
|
||||
'b','l','a','n','k','.','h','t','m','l',0};
|
||||
static const WCHAR base_url5[] = {'x','x','x',':','t','e','s','t','.','c','h','m',
|
||||
':',':','/','d','i','r','/','b','l','a','n','k','.','h','t','m','l',0};
|
||||
|
||||
static const WCHAR combined_url1[] = {'i','t','s',':',
|
||||
't','e','s','t','.','c','h','m',':',':','/','t','e','s','t','.','h','t','m','l',0};
|
||||
static const WCHAR combined_url2[] = {'i','t','s',':',
|
||||
't','e','s','t','.','c','h','m',':',':','/','d','i','r','/','t','e','s','t','.','h','t','m','l',0};
|
||||
static const WCHAR combined_url3[] = {'i','t','s',':',
|
||||
't','e','s','t',':','.','c','h','m',':',':','/','t','e','s','t','.','h','t','m','l',0};
|
||||
static const WCHAR combined_url4[] = {'i','t','s',':','t','e','s','t','.','c','h','m',
|
||||
':',':','b','l','a','n','k','.','h','t','m','l','t','e','s','t','.','h','t','m','l',0};
|
||||
static const WCHAR combined_url5[] = {'m','s','-','i','t','s',':',
|
||||
't','e','s','t','.','c','h','m',':',':','/','d','i','r','/','t','e','s','t','.','h','t','m','l',0};
|
||||
static const WCHAR combined_url6[] = {'m','k',':','@','M','S','I','T','S','t','o','r','e',':',
|
||||
't','e','s','t','.','c','h','m',':',':','/','d','i','r','/','t','e','s','t','.','h','t','m','l',0};
|
||||
|
||||
static const struct {
|
||||
LPCWSTR base_url;
|
||||
LPCWSTR rel_url;
|
||||
DWORD flags;
|
||||
HRESULT hres;
|
||||
LPCWSTR combined_url;
|
||||
} combine_tests[] = {
|
||||
{blank_url1, blank_url1, 0, STG_E_INVALIDNAME, NULL},
|
||||
{blank_url2, blank_url2, 0, STG_E_INVALIDNAME, NULL},
|
||||
{blank_url1, rel_url1, 0, S_OK, combined_url1},
|
||||
{blank_url1, rel_url2, 0, STG_E_INVALIDNAME, NULL},
|
||||
{blank_url1, rel_url3, 0, S_OK, combined_url1},
|
||||
{blank_url1, rel_url4, 0, STG_E_INVALIDNAME, NULL},
|
||||
{blank_url1, rel_url3, URL_ESCAPE_SPACES_ONLY|URL_DONT_ESCAPE_EXTRA_INFO, S_OK, combined_url1},
|
||||
{blank_url1, rel_url5, 0, S_OK, combined_url2},
|
||||
{rel_url1, rel_url2, 0, 0x80041001, NULL},
|
||||
{base_url1, rel_url1, 0, S_OK, combined_url3},
|
||||
{base_url2, rel_url1, 0, S_OK, combined_url2},
|
||||
{blank_url4, rel_url1, 0, S_OK, combined_url4},
|
||||
{base_url3, rel_url1, 0, S_OK, combined_url5},
|
||||
{base_url4, rel_url1, 0, S_OK, combined_url6},
|
||||
{base_url5, rel_url1, 0, INET_E_USE_DEFAULT_PROTOCOLHANDLER, NULL},
|
||||
{base_url2, rel_url3, 0, S_OK, combined_url1},
|
||||
};
|
||||
|
||||
static void test_its_protocol_info(IInternetProtocol *protocol)
|
||||
{
|
||||
IInternetProtocolInfo *info;
|
||||
|
@ -430,6 +491,30 @@ static void test_its_protocol_info(IInternetProtocol *protocol)
|
|||
}
|
||||
}
|
||||
|
||||
for(i=0; i < sizeof(combine_tests)/sizeof(combine_tests[0]); i++) {
|
||||
size = 0xdeadbeef;
|
||||
memset(buf, 0xfe, sizeof(buf));
|
||||
hres = IInternetProtocolInfo_CombineUrl(info, combine_tests[i].base_url,
|
||||
combine_tests[i].rel_url, combine_tests[i].flags, buf,
|
||||
sizeof(buf)/sizeof(WCHAR), &size, 0);
|
||||
ok(hres == combine_tests[i].hres, "[%d] CombineUrl returned %08x, expected %08x\n",
|
||||
i, hres, combine_tests[i].hres);
|
||||
ok(size == (combine_tests[i].combined_url ? lstrlenW(combine_tests[i].combined_url)+1
|
||||
: 0xdeadbeef), "[%d] unexpected size=%d\n", i, size);
|
||||
if(combine_tests[i].combined_url)
|
||||
ok(!lstrcmpW(combine_tests[i].combined_url, buf), "[%d] unexpected result\n", i);
|
||||
else
|
||||
ok(buf[0] == 0xfefe, "buf changed\n");
|
||||
}
|
||||
|
||||
size = 0xdeadbeef;
|
||||
memset(buf, 0xfe, sizeof(buf));
|
||||
hres = IInternetProtocolInfo_CombineUrl(info, blank_url1, rel_url1, 0, buf,
|
||||
1, &size, 0);
|
||||
ok(hres == E_OUTOFMEMORY, "CombineUrl failed: %08x\n", hres);
|
||||
ok(size == sizeof(combined_url1)/sizeof(WCHAR), "size=%d\n", size);
|
||||
ok(buf[0] == 0xfefe, "buf changed\n");
|
||||
|
||||
IInternetProtocolInfo_Release(info);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue