Commit 1db3e475 authored by Piotr Caban's avatar Piotr Caban Committed by Alexandre Julliard

urlmon: Fixed CoInternetGetSecurityUrl implementation.

parent 7d369354
......@@ -1240,28 +1240,44 @@ HRESULT WINAPI CoInternetCreateZoneManager(IServiceProvider* pSP, IInternetZoneM
*/
HRESULT WINAPI CoInternetGetSecurityUrl(LPCWSTR pwzUrl, LPWSTR *ppwzSecUrl, PSUACTION psuAction, DWORD dwReserved)
{
WCHAR url[INTERNET_MAX_URL_LENGTH], domain[INTERNET_MAX_URL_LENGTH];
WCHAR buf1[INTERNET_MAX_URL_LENGTH], buf2[INTERNET_MAX_URL_LENGTH];
LPWSTR url, domain;
DWORD len;
HRESULT hres;
TRACE("(%p,%p,%u,%u)\n", pwzUrl, ppwzSecUrl, psuAction, dwReserved);
hres = CoInternetParseUrl(pwzUrl, PARSE_SECURITY_URL, 0, url, INTERNET_MAX_URL_LENGTH, &len, 0);
if(hres==S_OK) {
if(psuAction == PSU_DEFAULT)
hres = CoInternetParseUrl(url, PARSE_SECURITY_DOMAIN, 0, domain,
INTERNET_MAX_URL_LENGTH, &len, 0);
url = buf1;
domain = buf2;
strcpyW(url, pwzUrl);
while(1) {
hres = CoInternetParseUrl(url, PARSE_SECURITY_URL, 0, domain, INTERNET_MAX_URL_LENGTH, &len, 0);
if(hres!=S_OK || !strcmpW(url, domain))
break;
if(url == buf1) {
url = buf2;
domain = buf1;
} else {
url = buf1;
domain = buf2;
}
}
if(psuAction==PSU_SECURITY_URL_ONLY || hres!=S_OK) {
len = lstrlenW(url)+1;
*ppwzSecUrl = CoTaskMemAlloc(len*sizeof(WCHAR));
if(!*ppwzSecUrl)
return E_OUTOFMEMORY;
if(psuAction==PSU_SECURITY_URL_ONLY) {
len = lstrlenW(url)+1;
*ppwzSecUrl = CoTaskMemAlloc(len*sizeof(WCHAR));
if(!*ppwzSecUrl)
return E_OUTOFMEMORY;
memcpy(*ppwzSecUrl, url, len*sizeof(WCHAR));
return S_OK;
}
memcpy(*ppwzSecUrl, url, len*sizeof(WCHAR));
return S_OK;
}
hres = CoInternetParseUrl(url, PARSE_SECURITY_DOMAIN, 0, domain,
INTERNET_MAX_URL_LENGTH, &len, 0);
if(SUCCEEDED(hres)) {
len++;
*ppwzSecUrl = CoTaskMemAlloc(len*sizeof(WCHAR));
if(!*ppwzSecUrl)
......@@ -1271,33 +1287,31 @@ HRESULT WINAPI CoInternetGetSecurityUrl(LPCWSTR pwzUrl, LPWSTR *ppwzSecUrl, PSUA
return S_OK;
}
if(psuAction == PSU_DEFAULT) {
hres = CoInternetParseUrl(pwzUrl, PARSE_ROOTDOCUMENT, 0, url, 0, &len, 0);
if(hres == S_FALSE) {
hres = CoInternetParseUrl(pwzUrl, PARSE_SCHEMA, 0, domain,
INTERNET_MAX_URL_LENGTH, &len, 0);
hres = CoInternetParseUrl(url, PARSE_ROOTDOCUMENT, 0, domain, 0, &len, 0);
if(hres == S_FALSE) {
hres = CoInternetParseUrl(url, PARSE_SCHEMA, 0, domain,
INTERNET_MAX_URL_LENGTH, &len, 0);
if(hres == S_OK) {
domain[len] = ':';
hres = CoInternetParseUrl(url, PARSE_DOMAIN, 0, domain+len+1,
INTERNET_MAX_URL_LENGTH-len-1, &len, 0);
if(hres == S_OK) {
domain[len] = ':';
hres = CoInternetParseUrl(pwzUrl, PARSE_DOMAIN, 0, domain+len+1,
INTERNET_MAX_URL_LENGTH-len-1, &len, 0);
if(hres == S_OK) {
len = lstrlenW(domain)+1;
*ppwzSecUrl = CoTaskMemAlloc(len*sizeof(WCHAR));
if(!*ppwzSecUrl)
return E_OUTOFMEMORY;
memcpy(*ppwzSecUrl, domain, len*sizeof(WCHAR));
return S_OK;
}
len = lstrlenW(domain)+1;
*ppwzSecUrl = CoTaskMemAlloc(len*sizeof(WCHAR));
if(!*ppwzSecUrl)
return E_OUTOFMEMORY;
memcpy(*ppwzSecUrl, domain, len*sizeof(WCHAR));
return S_OK;
}
}
}
len = lstrlenW(pwzUrl)+1;
len = lstrlenW(url)+1;
*ppwzSecUrl = CoTaskMemAlloc(len*sizeof(WCHAR));
if(!*ppwzSecUrl)
return E_OUTOFMEMORY;
memcpy(*ppwzSecUrl, pwzUrl, len*sizeof(WCHAR));
memcpy(*ppwzSecUrl, url, len*sizeof(WCHAR));
return S_OK;
}
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