Commit ebcb86d1 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

Added PARSE_PATH_FROM_URL action implementation.

parent fa34635c
......@@ -134,6 +134,31 @@ static HRESULT parse_encode(LPCWSTR url, DWORD flags, LPWSTR result, DWORD size,
return hres;
}
static HRESULT parse_path_from_url(LPCWSTR url, DWORD flags, LPWSTR result, DWORD size, DWORD *rsize)
{
IInternetProtocolInfo *protocol_info;
DWORD prsize;
HRESULT hres;
TRACE("(%s %08lx %p %ld %p)\n", debugstr_w(url), flags, result, size, rsize);
protocol_info = get_protocol_info(url);
if(protocol_info) {
hres = IInternetProtocolInfo_ParseUrl(protocol_info, url, PARSE_PATH_FROM_URL,
flags, result, size, rsize, 0);
if(SUCCEEDED(hres))
return hres;
}
prsize = size;
hres = PathCreateFromUrlW(url, result, &prsize, 0);
if(rsize)
*rsize = prsize;
return hres;
}
HRESULT WINAPI CoInternetParseUrl(LPCWSTR pwzUrl, PARSEACTION ParseAction, DWORD dwFlags,
LPWSTR pszResult, DWORD cchResult, DWORD *pcchResult, DWORD dwReserved)
{
......@@ -143,6 +168,8 @@ HRESULT WINAPI CoInternetParseUrl(LPCWSTR pwzUrl, PARSEACTION ParseAction, DWORD
switch(ParseAction) {
case PARSE_ENCODE:
return parse_encode(pwzUrl, dwFlags, pszResult, cchResult, pcchResult);
case PARSE_PATH_FROM_URL:
return parse_path_from_url(pwzUrl, dwFlags, pszResult, cchResult, pcchResult);
case PARSE_SCHEMA:
return parse_schema(pwzUrl, dwFlags, pszResult, cchResult, pcchResult);
default:
......
......@@ -212,6 +212,9 @@ static const WCHAR url4[] = {'f','i','l','e',':','s','o','m','e','%','2','0','f'
static const WCHAR url4e[] = {'f','i','l','e',':','s','o','m','e',' ','f','i','l','e',
'.','j','p','g',0};
static const WCHAR path3[] = {'c',':','\\','I','n','d','e','x','.','h','t','m',0};
static const WCHAR path4[] = {'s','o','m','e',' ','f','i','l','e','.','j','p','g',0};
static const WCHAR wszRes[] = {'r','e','s',0};
static const WCHAR wszFile[] = {'f','i','l','e',0};
static const WCHAR wszEmpty[] = {0};
......@@ -219,14 +222,16 @@ static const WCHAR wszEmpty[] = {0};
struct parse_test {
LPCWSTR url;
LPCWSTR encoded_url;
HRESULT path_hres;
LPCWSTR path;
LPCWSTR schema;
};
static const struct parse_test parse_tests[] = {
{url1, url1, wszRes},
{url2, url2, wszEmpty},
{url3, url3, wszFile},
{url4, url4e, wszFile}
{url1, url1, E_INVALIDARG, NULL, wszRes},
{url2, url2, E_INVALIDARG, NULL, wszEmpty},
{url3, url3, S_OK, path3, wszFile},
{url4, url4e, S_OK, path4, wszFile}
};
static void test_CoInternetParseUrl(void)
......@@ -251,6 +256,15 @@ static void test_CoInternetParseUrl(void)
ok(!lstrcmpW(parse_tests[i].encoded_url, buf), "[%d] wrong encoded url\n", i);
memset(buf, 0xf0, sizeof(buf));
hres = CoInternetParseUrl(parse_tests[i].url, PARSE_PATH_FROM_URL, 0, buf,
sizeof(buf)/sizeof(WCHAR), &size, 0);
ok(hres == parse_tests[i].path_hres, "[%d] path failed: %08lx\n", i, hres);
if(parse_tests[i].path) {
ok(size == lstrlenW(parse_tests[i].path), "[%d] wrong size\n", i);
ok(!lstrcmpW(parse_tests[i].path, buf), "[%d] wrong path\n", i);
}
memset(buf, 0xf0, sizeof(buf));
hres = CoInternetParseUrl(parse_tests[i].url, PARSE_SCHEMA, 0, buf,
sizeof(buf)/sizeof(WCHAR), &size, 0);
ok(hres == S_OK, "[%d] schema failed: %08lx\n", i, hres);
......
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