MSHTML: Added *ProtocolInfo::ParseUrl implementation
Jacek Caban
jack at itma.pwr.wroc.pl
Fri Sep 9 13:24:42 CDT 2005
Changelog:
Added *ProtocolInfo::ParseUrl implementation
-------------- next part --------------
Index: dlls/mshtml/protocol.c
===================================================================
RCS file: /home/wine/wine/dlls/mshtml/protocol.c,v
retrieving revision 1.12
diff -u -p -r1.12 protocol.c
--- dlls/mshtml/protocol.c 8 Sep 2005 18:55:18 -0000 1.12
+++ dlls/mshtml/protocol.c 9 Sep 2005 18:20:06 -0000
@@ -400,9 +400,25 @@ static HRESULT WINAPI AboutProtocolInfo_
PARSEACTION ParseAction, DWORD dwParseFlags, LPWSTR pwzResult, DWORD cchResult,
DWORD* pcchResult, DWORD dwReserved)
{
- FIXME("%p)->(%s %08x %08lx %p %ld %p %ld)\n", iface, debugstr_w(pwzUrl), ParseAction,
+ TRACE("%p)->(%s %08x %08lx %p %ld %p %ld)\n", iface, debugstr_w(pwzUrl), ParseAction,
dwParseFlags, pwzResult, cchResult, pcchResult, dwReserved);
- return E_NOTIMPL;
+
+ if(ParseAction == PARSE_SECURITY_URL) {
+ int len = lstrlenW(pwzUrl);
+
+ if(len >= cchResult)
+ return S_FALSE;
+
+ memcpy(pwzResult, pwzUrl, (len+1)*sizeof(WCHAR));
+ return S_OK;
+ }
+
+ if(ParseAction == PARSE_DOMAIN) {
+ /* Tests show that we don't have to do anything here */
+ return S_OK;
+ }
+
+ return INET_E_DEFAULT_ACTION;
}
static HRESULT WINAPI AboutProtocolInfo_CombineUrl(IInternetProtocolInfo *iface, LPCWSTR pwzBaseUrl,
@@ -749,9 +765,45 @@ static HRESULT WINAPI ResProtocolInfo_Pa
PARSEACTION ParseAction, DWORD dwParseFlags, LPWSTR pwzResult, DWORD cchResult,
DWORD* pcchResult, DWORD dwReserved)
{
- FIXME("%p)->(%s %08x %08lx %p %ld %p %ld)\n", iface, debugstr_w(pwzUrl), ParseAction,
+ TRACE("%p)->(%s %d %lx %p %ld %p %ld)\n", iface, debugstr_w(pwzUrl), ParseAction,
dwParseFlags, pwzResult, cchResult, pcchResult, dwReserved);
- return E_NOTIMPL;
+
+ if(ParseAction == PARSE_SECURITY_URL) {
+ WCHAR *ptr;
+ DWORD size;
+
+ static const WCHAR wszFile[] = {'f','i','l','e',':','/','/'};
+ static const WCHAR wszRes[] = {'r','e','s',':','/','/'};
+
+ if(strlenW(pwzUrl) <= sizeof(wszRes)/sizeof(WCHAR) || memcmp(pwzUrl, wszRes, sizeof(wszRes)))
+ return MK_E_SYNTAX;
+
+ ptr = strchrW(pwzUrl + sizeof(wszRes)/sizeof(WCHAR), '/');
+ if(!ptr)
+ return MK_E_SYNTAX;
+
+ size = ptr-pwzUrl + sizeof(wszFile)/sizeof(WCHAR) - sizeof(wszRes)/sizeof(WCHAR);
+ if(size >= cchResult)
+ return S_FALSE;
+
+ /* 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;
+
+ if(pcchResult)
+ *pcchResult = size;
+ return S_OK;
+ }
+
+ if(ParseAction == PARSE_DOMAIN) {
+ /* Tests show that we don't have to do anything here */
+ return S_OK;
+ }
+
+ return INET_E_DEFAULT_ACTION;
}
static HRESULT WINAPI ResProtocolInfo_CombineUrl(IInternetProtocolInfo *iface, LPCWSTR pwzBaseUrl,
Index: dlls/mshtml/tests/protocol.c
===================================================================
RCS file: /home/wine/wine/dlls/mshtml/tests/protocol.c,v
retrieving revision 1.6
diff -u -p -r1.6 protocol.c
--- dlls/mshtml/tests/protocol.c 16 Aug 2005 15:59:50 -0000 1.6
+++ dlls/mshtml/tests/protocol.c 9 Sep 2005 18:20:06 -0000
@@ -247,8 +247,48 @@ static void test_res_protocol(void)
hres = IUnknown_QueryInterface(unk, &IID_IInternetProtocolInfo, (void**)&protocol_info);
ok(hres == S_OK, "Could not get IInternetProtocolInfo interface: %08lx\n", hres);
if(SUCCEEDED(hres)) {
- /* TODO: test IInternetProtocol interface */
- IInternetProtocol_Release(protocol_info);
+ WCHAR buf[128];
+ DWORD size;
+ int i;
+
+ for(i = PARSE_CANONICALIZE; i <= PARSE_UNESCAPE; i++) {
+ if(i != PARSE_SECURITY_URL && i != PARSE_DOMAIN) {
+ hres = IInternetProtocolInfo_ParseUrl(protocol_info, blank_url, i, 0, buf,
+ sizeof(buf)/sizeof(buf[0]), &size, 0);
+ ok(hres == INET_E_DEFAULT_ACTION,
+ "[%d] failed: %08lx, expected INET_E_DEFAULT_ACTION\n", i, hres);
+ }
+ }
+
+ 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: %08lx\n", hres);
+
+ hres = IInternetProtocolInfo_ParseUrl(protocol_info, blank_url, PARSE_SECURITY_URL, 0, buf,
+ 3, &size, 0);
+ ok(hres == S_FALSE, "ParseUrl failed: %08lx, expected S_FALSE\n", hres);
+
+ hres = IInternetProtocolInfo_ParseUrl(protocol_info, wrong_url1, PARSE_SECURITY_URL, 0, buf,
+ sizeof(buf)/sizeof(buf[0]), &size, 0);
+ ok(hres == MK_E_SYNTAX, "ParseUrl failed: %08lx, expected MK_E_SYNTAX\n", hres);
+
+ buf[0] = '?';
+ hres = IInternetProtocolInfo_ParseUrl(protocol_info, blank_url, PARSE_DOMAIN, 0, buf,
+ sizeof(buf)/sizeof(buf[0]), &size, 0);
+ ok(hres == S_OK, "ParseUrl failed: %08lx\n", hres);
+ ok(buf[0] == '?', "buf changed\n");
+
+ hres = IInternetProtocolInfo_ParseUrl(protocol_info, wrong_url1, PARSE_DOMAIN, 0, buf,
+ sizeof(buf)/sizeof(buf[0]), &size, 0);
+ ok(hres == S_OK, "ParseUrl failed: %08lx, expected MK_E_SYNTAX\n", hres);
+ ok(buf[0] == '?', "buf changed\n");
+
+ hres = IInternetProtocolInfo_ParseUrl(protocol_info, blank_url, PARSE_UNESCAPE+1, 0, buf,
+ sizeof(buf)/sizeof(buf[0]), &size, 0);
+ ok(hres == INET_E_DEFAULT_ACTION,
+ "ParseUrl failed: %08lx, expected INET_E_DEFAULT_ACTION\n", hres);
+
+ IInternetProtocolInfo_Release(protocol_info);
}
hres = IUnknown_QueryInterface(unk, &IID_IClassFactory, (void**)&factory);
@@ -352,8 +392,45 @@ static void test_about_protocol(void)
hres = IUnknown_QueryInterface(unk, &IID_IInternetProtocolInfo, (void**)&protocol_info);
ok(hres == S_OK, "Could not get IInternetProtocolInfo interface: %08lx\n", hres);
if(SUCCEEDED(hres)) {
- /* TODO: test IInternetProtocol interface */
- IInternetProtocol_Release(protocol_info);
+ WCHAR buf[128];
+ DWORD size;
+ int i;
+
+ for(i = PARSE_CANONICALIZE; i <= PARSE_UNESCAPE; i++) {
+ if(i != PARSE_SECURITY_URL && i != PARSE_DOMAIN) {
+ hres = IInternetProtocolInfo_ParseUrl(protocol_info, blank_url, i, 0, buf,
+ sizeof(buf)/sizeof(buf[0]), &size, 0);
+ ok(hres == INET_E_DEFAULT_ACTION,
+ "[%d] failed: %08lx, expected INET_E_DEFAULT_ACTION\n", i, hres);
+ }
+ }
+
+ 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: %08lx\n", hres);
+ ok(!lstrcmpW(blank_url, buf), "buf != blank_url\n");
+
+ hres = IInternetProtocolInfo_ParseUrl(protocol_info, blank_url, PARSE_SECURITY_URL, 0, buf,
+ 3, &size, 0);
+ ok(hres == S_FALSE, "ParseUrl failed: %08lx, expected S_FALSE\n", hres);
+
+ hres = IInternetProtocolInfo_ParseUrl(protocol_info, test_url, PARSE_SECURITY_URL, 0, buf,
+ sizeof(buf)/sizeof(buf[0]), &size, 0);
+ ok(hres == S_OK, "ParseUrl failed: %08lx\n", hres);
+ ok(!lstrcmpW(test_url, buf), "buf != test_url\n");
+
+ buf[0] = '?';
+ hres = IInternetProtocolInfo_ParseUrl(protocol_info, blank_url, PARSE_DOMAIN, 0, buf,
+ sizeof(buf)/sizeof(buf[0]), &size, 0);
+ ok(hres == S_OK, "ParseUrl failed: %08lx\n", hres);
+ ok(buf[0] == '?', "buf changed\n");
+
+ hres = IInternetProtocolInfo_ParseUrl(protocol_info, blank_url, PARSE_UNESCAPE+1, 0, buf,
+ sizeof(buf)/sizeof(buf[0]), &size, 0);
+ ok(hres == INET_E_DEFAULT_ACTION,
+ "ParseUrl failed: %08lx, expected INET_E_DEFAULT_ACTION\n", hres);
+
+ IInternetProtocolInfo_Release(protocol_info);
}
hres = IUnknown_QueryInterface(unk, &IID_IClassFactory, (void**)&factory);
More information about the wine-patches
mailing list