diff --git a/dlls/urlmon/internet.c b/dlls/urlmon/internet.c index f9023a8ba8c..22ff80d0a50 100644 --- a/dlls/urlmon/internet.c +++ b/dlls/urlmon/internet.c @@ -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: diff --git a/dlls/urlmon/tests/misc.c b/dlls/urlmon/tests/misc.c index 00d96cb9dba..96a77405529 100644 --- a/dlls/urlmon/tests/misc.c +++ b/dlls/urlmon/tests/misc.c @@ -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) @@ -250,6 +255,15 @@ static void test_CoInternetParseUrl(void) ok(size == lstrlenW(parse_tests[i].encoded_url), "[%d] wrong size\n", i); 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);