Commit 4f7748b9 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

mshtml: Return full patch in res protocol's secure URL.

parent cc159d83
......@@ -833,8 +833,9 @@ static HRESULT WINAPI ResProtocolInfo_ParseUrl(IInternetProtocolInfo *iface, LPC
dwParseFlags, pwzResult, cchResult, pcchResult, dwReserved);
if(ParseAction == PARSE_SECURITY_URL) {
WCHAR file_part[MAX_PATH], full_path[MAX_PATH];
WCHAR *ptr;
DWORD size;
DWORD size, len;
static const WCHAR wszFile[] = {'f','i','l','e',':','/','/'};
static const WCHAR wszRes[] = {'r','e','s',':','/','/'};
......@@ -846,19 +847,29 @@ static HRESULT WINAPI ResProtocolInfo_ParseUrl(IInternetProtocolInfo *iface, LPC
if(!ptr)
return E_INVALIDARG;
size = ptr-pwzUrl + sizeof(wszFile)/sizeof(WCHAR) - sizeof(wszRes)/sizeof(WCHAR);
if(size >= cchResult)
return S_FALSE;
len = ptr - (pwzUrl + sizeof(wszRes)/sizeof(WCHAR));
if(len > sizeof(file_part)/sizeof(WCHAR)) {
FIXME("Too long URL\n");
return MK_E_SYNTAX;
}
/* FIXME: return full path */
memcpy(pwzResult, wszFile, sizeof(wszFile));
memcpy(pwzResult + sizeof(wszFile)/sizeof(WCHAR),
pwzUrl + sizeof(wszRes)/sizeof(WCHAR),
size*sizeof(WCHAR) - sizeof(wszFile));
pwzResult[size] = 0;
memcpy(file_part, pwzUrl + sizeof(wszRes)/sizeof(WCHAR), len*sizeof(WCHAR));
file_part[len] = 0;
len = SearchPathW(NULL, file_part, NULL, sizeof(full_path)/sizeof(WCHAR), full_path, NULL);
if(!len) {
WARN("Could not find file %s\n", debugstr_w(file_part));
return MK_E_SYNTAX;
}
size = sizeof(wszFile)/sizeof(WCHAR) + len + 1;
if(pcchResult)
*pcchResult = size;
if(size >= cchResult)
return S_FALSE;
memcpy(pwzResult, wszFile, sizeof(wszFile));
memcpy(pwzResult + sizeof(wszFile)/sizeof(WCHAR), full_path, (len+1)*sizeof(WCHAR));
return S_OK;
}
......
......@@ -70,6 +70,13 @@ static const WCHAR about_blank_url[] = {'a','b','o','u','t',':','b','l','a','n',
static const WCHAR about_test_url[] = {'a','b','o','u','t',':','t','e','s','t',0};
static const WCHAR about_res_url[] = {'r','e','s',':','b','l','a','n','k',0};
static const char *debugstr_w(LPCWSTR str)
{
static char buf[1024];
WideCharToMultiByte(CP_ACP, 0, str, -1, buf, sizeof(buf), NULL, NULL);
return buf;
}
static HRESULT WINAPI ProtocolSink_QueryInterface(IInternetProtocolSink *iface, REFIID riid, void **ppv)
{
if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IInternetProtocolSink, riid)) {
......@@ -247,6 +254,29 @@ static void protocol_start(IInternetProtocol *protocol, LPCWSTR url)
CHECK_CALLED(ReportResult);
}
static void res_sec_url_cmp(LPCWSTR url, DWORD size, LPCWSTR file)
{
WCHAR buf[MAX_PATH];
DWORD len;
static const WCHAR fileW[] = {'f','i','l','e',':','/','/'};
if(size < sizeof(fileW)/sizeof(WCHAR) || memcmp(url, fileW, sizeof(fileW))) {
ok(0, "wrong URL protocol\n");
return;
}
len = SearchPathW(NULL, file, NULL, sizeof(buf)/sizeof(WCHAR), buf, NULL);
if(!len) {
ok(0, "SearchPath failed: %u\n", GetLastError());
return;
}
len += sizeof(fileW)/sizeof(WCHAR)+1;
ok(len == size, "wrong size %u, expected %u\n", size, len);
ok(!lstrcmpW(url + sizeof(fileW)/sizeof(WCHAR), buf), "wrong file part %s\n", debugstr_w(url));
}
static void test_res_protocol(void)
{
IInternetProtocolInfo *protocol_info;
......@@ -265,7 +295,9 @@ static void test_res_protocol(void)
{'r','e','s',':','/','/','m','s','h','t','m','l','.','d','l','l','/','x','x','.','h','t','m',0};
static const WCHAR wrong_url4[] =
{'r','e','s',':','/','/','x','x','.','d','l','l','/','b','l','a','n','k','.','h','t','m',0};
static const WCHAR wrong_url5[] =
{'r','e','s',':','/','/','s','h','t','m','l','.','d','l','l','/','b','l','a','n','k','.','h','t','m',0};
static const WCHAR mshtml_dllW[] = {'m','s','h','t','m','l','.','d','l','l',0};
hres = CoGetClassObject(&CLSID_ResProtocol, CLSCTX_INPROC_SERVER, NULL, &IID_IUnknown, (void**)&unk);
ok(hres == S_OK, "CoGetClassObject failed: %08x\n", hres);
......@@ -291,16 +323,23 @@ static void test_res_protocol(void)
hres = IInternetProtocolInfo_ParseUrl(protocol_info, blank_url, PARSE_SECURITY_URL, 0, buf,
sizeof(buf)/sizeof(buf[0]), &size, 0);
ok(hres == S_OK, "ParseUrl failed: %08x\n", hres);
res_sec_url_cmp(buf, size, mshtml_dllW);
size = 0;
hres = IInternetProtocolInfo_ParseUrl(protocol_info, blank_url, PARSE_SECURITY_URL, 0, buf,
3, &size, 0);
ok(hres == S_FALSE, "ParseUrl failed: %08x, expected S_FALSE\n", hres);
ok(size, "size=0\n");
hres = IInternetProtocolInfo_ParseUrl(protocol_info, wrong_url1, PARSE_SECURITY_URL, 0, buf,
sizeof(buf)/sizeof(buf[0]), &size, 0);
ok(hres == MK_E_SYNTAX || hres == E_INVALIDARG,
"ParseUrl failed: %08x, expected MK_E_SYNTAX\n", hres);
hres = IInternetProtocolInfo_ParseUrl(protocol_info, wrong_url5, PARSE_SECURITY_URL, 0, buf,
sizeof(buf)/sizeof(buf[0]), &size, 0);
ok(hres == MK_E_SYNTAX, "ParseUrl failed: %08x, expected MK_E_SYNTAX\n", hres);
size = 0xdeadbeef;
buf[0] = '?';
hres = IInternetProtocolInfo_ParseUrl(protocol_info, blank_url, PARSE_DOMAIN, 0, buf,
......
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