Commit 18069b2d authored by Piotr Caban's avatar Piotr Caban Committed by Alexandre Julliard

urlmon: Added PARSE_ROOTDOCUMENT to CoInternetParseUrl.

parent 3adfe170
......@@ -38,6 +38,9 @@ static HRESULT parse_schema(LPCWSTR url, DWORD flags, LPWSTR result, DWORD size,
if(ptr)
len = ptr-url;
if(rsize)
*rsize = len;
if(len >= size)
return E_POINTER;
......@@ -45,9 +48,6 @@ static HRESULT parse_schema(LPCWSTR url, DWORD flags, LPWSTR result, DWORD size,
memcpy(result, url, len*sizeof(WCHAR));
result[len] = 0;
if(rsize)
*rsize = len;
return S_OK;
}
......@@ -200,6 +200,70 @@ static HRESULT parse_domain(LPCWSTR url, DWORD flags, LPWSTR result,
return S_OK;
}
static HRESULT parse_rootdocument(LPCWSTR url, DWORD flags, LPWSTR result,
DWORD size, DWORD *rsize)
{
IInternetProtocolInfo *protocol_info;
PARSEDURLW url_info;
HRESULT hres;
TRACE("(%s %08x %p %d %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_ROOTDOCUMENT,
flags, result, size, rsize, 0);
IInternetProtocolInfo_Release(protocol_info);
if(SUCCEEDED(hres))
return hres;
}
url_info.cbSize = sizeof(url_info);
if(FAILED(ParseURLW(url, &url_info)))
return E_FAIL;
switch(url_info.nScheme) {
case URL_SCHEME_FTP:
case URL_SCHEME_HTTP:
case URL_SCHEME_HTTPS:
if(url_info.cchSuffix<3 || *(url_info.pszSuffix)!='/'
|| *(url_info.pszSuffix+1)!='/')
return E_FAIL;
if(size < url_info.cchProtocol+3) {
size = 0;
hres = UrlGetPartW(url, result, &size, URL_PART_HOSTNAME, flags);
if(rsize)
*rsize = size+url_info.cchProtocol+3;
if(hres == E_POINTER)
return S_FALSE;
return hres;
}
size -= url_info.cchProtocol+3;
hres = UrlGetPartW(url, result+url_info.cchProtocol+3,
&size, URL_PART_HOSTNAME, flags);
if(hres == E_POINTER)
return S_FALSE;
if(FAILED(hres))
return E_FAIL;
if(rsize)
*rsize = size+url_info.cchProtocol+3;
memcpy(result, url, (url_info.cchProtocol+3)*sizeof(WCHAR));
return hres;
default:
return E_FAIL;
}
}
/**************************************************************************
* CoInternetParseUrl (URLMON.@)
*/
......@@ -224,6 +288,8 @@ HRESULT WINAPI CoInternetParseUrl(LPCWSTR pwzUrl, PARSEACTION ParseAction, DWORD
return parse_security_domain(pwzUrl, dwFlags, pszResult, cchResult, pcchResult);
case PARSE_DOMAIN:
return parse_domain(pwzUrl, dwFlags, pszResult, cchResult, pcchResult);
case PARSE_ROOTDOCUMENT:
return parse_rootdocument(pwzUrl, dwFlags, pszResult, cchResult, pcchResult);
default:
FIXME("not supported action %d\n", ParseAction);
}
......
......@@ -271,6 +271,8 @@ static const WCHAR wszAbout[] = {'a','b','o','u','t',0};
static const WCHAR wszEmpty[] = {0};
static const WCHAR wszWineHQ[] = {'w','w','w','.','w','i','n','e','h','q','.','o','r','g',0};
static const WCHAR wszHttpWineHQ[] = {'h','t','t','p',':','/','/','w','w','w','.',
'w','i','n','e','h','q','.','o','r','g',0};
struct parse_test {
LPCWSTR url;
......@@ -281,15 +283,17 @@ struct parse_test {
LPCWSTR schema;
LPCWSTR domain;
HRESULT domain_hres;
LPCWSTR rootdocument;
HRESULT rootdocument_hres;
};
static const struct parse_test parse_tests[] = {
{url1, S_OK, url1, E_INVALIDARG, NULL, wszRes, NULL, E_FAIL},
{url2, E_FAIL, url2, E_INVALIDARG, NULL, wszEmpty, NULL, E_FAIL},
{url3, E_FAIL, url3, S_OK, path3, wszFile, wszEmpty, S_OK},
{url4, E_FAIL, url4e, S_OK, path4, wszFile, wszEmpty, S_OK},
{url5, E_FAIL, url5, E_INVALIDARG, NULL, wszHttp, wszWineHQ, S_OK},
{url6, S_OK, url6, E_INVALIDARG, NULL, wszAbout, NULL, E_FAIL}
{url1, S_OK, url1, E_INVALIDARG, NULL, wszRes, NULL, E_FAIL, NULL, E_FAIL},
{url2, E_FAIL, url2, E_INVALIDARG, NULL, wszEmpty, NULL, E_FAIL, NULL, E_FAIL},
{url3, E_FAIL, url3, S_OK, path3, wszFile, wszEmpty, S_OK, NULL, E_FAIL},
{url4, E_FAIL, url4e, S_OK, path4, wszFile, wszEmpty, S_OK, NULL, E_FAIL},
{url5, E_FAIL, url5, E_INVALIDARG, NULL, wszHttp, wszWineHQ, S_OK, wszHttpWineHQ, S_OK},
{url6, S_OK, url6, E_INVALIDARG, NULL, wszAbout, NULL, E_FAIL, NULL, E_FAIL},
};
static void test_CoInternetParseUrl(void)
......@@ -342,6 +346,13 @@ static void test_CoInternetParseUrl(void)
ok(hres == parse_tests[i].domain_hres, "[%d] domain failed: %08x\n", i, hres);
if(parse_tests[i].domain)
ok(!lstrcmpW(parse_tests[i].domain, buf), "[%d] wrong domain, received %s\n", i, wine_dbgstr_w(buf));
memset(buf, 0xf0, sizeof(buf));
hres = CoInternetParseUrl(parse_tests[i].url, PARSE_ROOTDOCUMENT, 0, buf,
sizeof(buf)/sizeof(WCHAR), &size, 0);
ok(hres == parse_tests[i].rootdocument_hres, "[%d] rootdocument failed: %08x\n", i, hres);
if(parse_tests[i].rootdocument)
ok(!lstrcmpW(parse_tests[i].rootdocument, buf), "[%d] wrong rootdocument, received %s\n", i, wine_dbgstr_w(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