urlmon: Added pluggable protocol support to CoInternetParseIUri.

This commit is contained in:
Thomas Mullaly 2010-12-08 21:28:46 -05:00 committed by Alexandre Julliard
parent f7192d329e
commit 4e1ff0b8cd
2 changed files with 68 additions and 26 deletions

View File

@ -62,6 +62,7 @@
}while(0)
DEFINE_EXPECT(CombineUrl);
DEFINE_EXPECT(ParseUrl);
static HRESULT (WINAPI *pCreateUri)(LPCWSTR, DWORD, DWORD_PTR, IUri**);
static HRESULT (WINAPI *pCreateUriWithFragment)(LPCWSTR, LPCWSTR, DWORD, DWORD_PTR, IUri**);
@ -83,6 +84,12 @@ static const WCHAR combine_resultW[] = {'z','i','p',':','t','e','s','t',0};
static const WCHAR winetestW[] = {'w','i','n','e','t','e','s','t',0};
static const WCHAR parse_urlW[] = {'w','i','n','e','t','e','s','t',':','t','e','s','t',0};
static const WCHAR parse_resultW[] = {'z','i','p',':','t','e','s','t',0};
static PARSEACTION parse_action;
static DWORD parse_flags;
typedef struct _uri_create_flag_test {
DWORD flags;
HRESULT expected;
@ -9300,8 +9307,17 @@ static HRESULT WINAPI InternetProtocolInfo_ParseUrl(IInternetProtocolInfo *iface
PARSEACTION ParseAction, DWORD dwParseFlags, LPWSTR pwzResult, DWORD cchResult,
DWORD *pcchResult, DWORD dwReserved)
{
ok(0, "unexpected call %d\n", ParseAction);
return E_NOTIMPL;
CHECK_EXPECT(ParseUrl);
ok(!lstrcmpW(pwzUrl, parse_urlW), "Error: Expected %s, but got %s instead.\n",
wine_dbgstr_w(parse_urlW), wine_dbgstr_w(pwzUrl));
ok(ParseAction == parse_action, "Error: Expected %d, but got %d.\n", parse_action, ParseAction);
ok(dwParseFlags == parse_flags, "Error: Expected 0x%08x, but got 0x%08x.\n", parse_flags, dwParseFlags);
ok(cchResult == 200, "Error: Got %d.\n", cchResult);
memcpy(pwzResult, parse_resultW, sizeof(parse_resultW));
*pcchResult = lstrlenW(parse_resultW);
return S_OK;
}
static HRESULT WINAPI InternetProtocolInfo_CombineUrl(IInternetProtocolInfo *iface,
@ -9725,6 +9741,36 @@ static void test_CoInternetParseIUri(void) {
}
}
static void test_CoInternetParseIUri_Pluggable(void) {
HRESULT hr;
IUri *uri = NULL;
hr = pCreateUri(parse_urlW, 0, 0, &uri);
ok(SUCCEEDED(hr), "Error: Expected CreateUri to succeed, but got 0x%08x.\n", hr);
if(SUCCEEDED(hr)) {
WCHAR result[200];
DWORD result_len;
SET_EXPECT(ParseUrl);
parse_action = PARSE_CANONICALIZE;
parse_flags = URL_UNESCAPE|URL_ESCAPE_UNSAFE;
hr = pCoInternetParseIUri(uri, parse_action, parse_flags, result, 200, &result_len, 0);
ok(hr == S_OK, "Error: CoInternetParseIUri returned 0x%08x, expected 0x%08x.\n", hr, S_OK);
CHECK_CALLED(ParseUrl);
if(SUCCEEDED(hr)) {
ok(result_len == lstrlenW(parse_resultW), "Error: Expected %d, but got %d.\n",
lstrlenW(parse_resultW), result_len);
ok(!lstrcmpW(result, parse_resultW), "Error: Expected %s, but got %s.\n",
wine_dbgstr_w(parse_resultW), wine_dbgstr_w(result));
}
}
if(uri) IUri_Release(uri);
}
START_TEST(uri) {
HMODULE hurlmon;
@ -9831,5 +9877,8 @@ START_TEST(uri) {
trace("test CoInternetCombineUrlEx Pluggable...\n");
test_CoInternetCombineUrlEx_Pluggable();
trace("test CoInternetParseIUri pluggable...\n");
test_CoInternetParseIUri_Pluggable();
unregister_protocols();
}

View File

@ -6203,6 +6203,7 @@ static HRESULT parse_canonicalize(const Uri *uri, DWORD flags, LPWSTR output,
!(flags & URL_ESCAPE_SPACES_ONLY) &&
!(flags & URL_ESCAPE_PERCENT);
/* Check if the dot segments need to be removed from the
* path component.
*/
@ -6612,6 +6613,7 @@ HRESULT WINAPI CoInternetParseIUri(IUri *pIUri, PARSEACTION ParseAction, DWORD d
{
HRESULT hr;
Uri *uri;
IInternetProtocolInfo *info;
TRACE("(%p %d %x %p %d %p %x)\n", pIUri, ParseAction, dwFlags, pwzResult,
cchResult, pcchResult, (DWORD)dwReserved);
@ -6624,44 +6626,35 @@ HRESULT WINAPI CoInternetParseIUri(IUri *pIUri, PARSEACTION ParseAction, DWORD d
return E_INVALIDARG;
}
if(!(uri = get_uri_obj(pIUri))) {
*pcchResult = 0;
FIXME("(%p %d %x %p %d %p %x) Unknown IUri's not supported for this action.\n",
pIUri, ParseAction, dwFlags, pwzResult, cchResult, pcchResult, (DWORD)dwReserved);
return E_NOTIMPL;
}
info = get_protocol_info(uri->canon_uri);
if(info) {
hr = IInternetProtocolInfo_ParseUrl(info, uri->canon_uri, ParseAction, dwFlags,
pwzResult, cchResult, pcchResult, 0);
IInternetProtocolInfo_Release(info);
if(SUCCEEDED(hr)) return hr;
}
switch(ParseAction) {
case PARSE_CANONICALIZE:
if(!(uri = get_uri_obj(pIUri))) {
*pcchResult = 0;
FIXME("(%p %d %x %p %d %p %x) Unknown IUri's not supported for this action.\n",
pIUri, ParseAction, dwFlags, pwzResult, cchResult, pcchResult, (DWORD)dwReserved);
return E_NOTIMPL;
}
hr = parse_canonicalize(uri, dwFlags, pwzResult, cchResult, pcchResult);
break;
case PARSE_FRIENDLY:
hr = parse_friendly(pIUri, pwzResult, cchResult, pcchResult);
break;
case PARSE_ROOTDOCUMENT:
if(!(uri = get_uri_obj(pIUri))) {
*pcchResult = 0;
FIXME("(%p %d %x %p %d %p %x) Unknown IUri's not supported for this action.\n",
pIUri, ParseAction, dwFlags, pwzResult, cchResult, pcchResult, (DWORD)dwReserved);
return E_NOTIMPL;
}
hr = parse_rootdocument(uri, pwzResult, cchResult, pcchResult);
break;
case PARSE_DOCUMENT:
if(!(uri = get_uri_obj(pIUri))) {
*pcchResult = 0;
FIXME("(%p %d %x %p %d %p %x) Unknown IUri's not supported for this action.\n",
pIUri, ParseAction, dwFlags, pwzResult, cchResult, pcchResult, (DWORD)dwReserved);
return E_NOTIMPL;
}
hr = parse_document(uri, pwzResult, cchResult, pcchResult);
break;
case PARSE_PATH_FROM_URL:
if(!(uri = get_uri_obj(pIUri))) {
*pcchResult = 0;
FIXME("(%p %d %x %p %d %p %x) Unknown IUri's not supported for this action.\n",
pIUri, ParseAction, dwFlags, pwzResult, cchResult, pcchResult, (DWORD)dwReserved);
return E_NOTIMPL;
}
hr = parse_path_from_url(uri, pwzResult, cchResult, pcchResult);
break;
case PARSE_URL_FROM_PATH: