urlmon: Improved MapUrlToZone{Ex2} and GetSecurityId support.

oldstable
Thomas Mullaly 2011-09-15 21:36:18 -04:00 committed by Alexandre Julliard
parent 8fc8823d5c
commit 253fccc82e
2 changed files with 53 additions and 3 deletions

View File

@ -62,6 +62,15 @@ static inline BOOL is_drive_path(const WCHAR *path)
return isalphaW(*path) && *(path+1) == ':';
}
/* List of schemes types Windows seems to expect to be hierarchical. */
static inline BOOL is_hierarchical_scheme(URL_SCHEME type) {
return(type == URL_SCHEME_HTTP || type == URL_SCHEME_FTP ||
type == URL_SCHEME_GOPHER || type == URL_SCHEME_NNTP ||
type == URL_SCHEME_TELNET || type == URL_SCHEME_WAIS ||
type == URL_SCHEME_FILE || type == URL_SCHEME_HTTPS ||
type == URL_SCHEME_RES);
}
/********************************************************************
* get_string_from_reg [internal]
*
@ -466,6 +475,19 @@ static HRESULT get_zone_from_domains(IUri *uri, DWORD *zone)
if(FAILED(hres))
return hres;
/* Known hierarchical scheme types must have a host. If they don't Windows
* assigns URLZONE_INVALID to the zone.
*/
if((scheme_type != URL_SCHEME_UNKNOWN && scheme_type != URL_SCHEME_FILE)
&& is_hierarchical_scheme(scheme_type) && !*host) {
*zone = URLZONE_INVALID;
SysFreeString(host);
/* The MapUrlToZone functions return S_OK when this condition occurs. */
return S_OK;
}
hres = IUri_GetSchemeName(uri, &scheme);
if(FAILED(hres)) {
SysFreeString(host);
@ -695,8 +717,8 @@ static HRESULT get_security_id(LPCWSTR url, BYTE *secid, DWORD *secid_len)
static const WCHAR wszFile[] = {'f','i','l','e',':'};
hres = map_url_to_zone(url, &zone, &secur_url);
if(FAILED(hres))
return hres == 0x80041001 ? E_INVALIDARG : hres;
if(zone == URLZONE_INVALID)
return (hres == 0x80041001 || hres == S_OK) ? E_INVALIDARG : hres;
/* file protocol is a special case */
if(strlenW(secur_url) >= sizeof(wszFile)/sizeof(WCHAR)

View File

@ -100,6 +100,8 @@ static const WCHAR url10[] = {'f','i','l','e',':','/','/','s','o','m','e','%','2
'.','j','p','g',0};
static const WCHAR url11[] = {'f','i','l','e',':','/','/','c',':','/','I','n','d','e','x','.','h','t','m',0};
static const WCHAR url12[] = {'f','i','l','e',':','/','/','/','c',':','/','I','n','d','e','x','.','h','t','m',0};
static const WCHAR url13[] = {'h','t','t','p',':','g','o','o','g','l','e','.','c','o','m',0};
static const WCHAR url14[] = {'z','i','p',':','t','e','s','t','i','n','g','.','c','o','m','/','t','e','s','t','i','n','g',0};
static const WCHAR url4e[] = {'f','i','l','e',':','s','o','m','e',' ','f','i','l','e',
'.','j','p','g',0};
@ -121,6 +123,8 @@ static const BYTE secid7[] = {'f','t','p',':','z','o','n','e','3',
'.','w','i','n','e','t','e','s','t',3,0,0,0};
static const BYTE secid10[] =
{'f','i','l','e',':','s','o','m','e','%','2','0','f','i','l','e','.','j','p','g',3,0,0,0};
static const BYTE secid14[] =
{'z','i','p',':','t','e','s','t','i','n','g','.','c','o','m','/','t','e','s','t','i','n','g',3,0,0,0};
static const BYTE secid10_2[] =
{'f','i','l','e',':','s','o','m','e',' ','f','i','l','e','.','j','p','g',3,0,0,0};
@ -415,6 +419,28 @@ static void test_SecurityManager(void)
!memcmp(buf, secid10_2, size), /* win2k3 */
"wrong secid\n");
zone = 100;
hres = IInternetSecurityManager_MapUrlToZone(secmgr, url13, &zone, 0);
ok(hres == S_OK, "MapUrlToZone failed: %08x\n", hres);
ok(zone == URLZONE_INVALID || broken(zone == URLZONE_INTERNET), "zone=%d\n", zone);
size = sizeof(buf);
memset(buf, 0xf0, sizeof(buf));
hres = IInternetSecurityManager_GetSecurityId(secmgr, url13, buf, &size, 0);
ok(hres == E_INVALIDARG || broken(hres == S_OK), "GetSecurityId failed: %08x\n", hres);
zone = 100;
hres = IInternetSecurityManager_MapUrlToZone(secmgr, url14, &zone, 0);
ok(hres == S_OK, "MapUrlToZone failed: %08x, expected S_OK\n", hres);
ok(zone == URLZONE_INTERNET, "zone=%d\n", zone);
size = sizeof(buf);
memset(buf, 0xf0, sizeof(buf));
hres = IInternetSecurityManager_GetSecurityId(secmgr, url14, buf, &size, 0);
ok(hres == S_OK, "GetSecurityId failed: %08x, expected S_OK\n", hres);
todo_wine ok(size == sizeof(secid14), "size=%d\n", size);
todo_wine ok(!memcmp(buf, secid14, size), "wrong secid\n");
zone = 100;
hres = IInternetSecurityManager_MapUrlToZone(secmgr, NULL, &zone, 0);
ok(hres == E_INVALIDARG, "MapUrlToZone failed: %08x, expected E_INVALIDARG\n", hres);
@ -1734,7 +1760,9 @@ static const struct {
{"ftp://zone3.winetest/file.test",0,0,URLZONE_INTERNET},
{"/file/testing/test.test",Uri_CREATE_ALLOW_RELATIVE,0,URLZONE_INTERNET},
{"zip://testing.com/",0,0,URLZONE_INTERNET},
{"zip:testing.com",0,0,URLZONE_INTERNET}
{"zip:testing.com",0,0,URLZONE_INTERNET},
{"http:google.com",0,S_OK,URLZONE_INVALID},
{"http:/google.com",0,S_OK,URLZONE_INVALID}
};
static void test_SecurityManagerEx2(void)