Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
98d5dfb8
Commit
98d5dfb8
authored
Aug 22, 2011
by
Thomas Mullaly
Committed by
Alexandre Julliard
Sep 05, 2011
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
urlmon: Added basic MapUrlToZoneEx2 implementation.
parent
e0dfbd6a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
112 additions
and
41 deletions
+112
-41
sec_mgr.c
dlls/urlmon/sec_mgr.c
+99
-32
sec_mgr.c
dlls/urlmon/tests/sec_mgr.c
+13
-9
No files found.
dlls/urlmon/sec_mgr.c
View file @
98d5dfb8
...
...
@@ -57,6 +57,11 @@ static const WCHAR wszZoneMapDomainsKey[] = {'S','o','f','t','w','a','r','e','\\
'Z'
,
'o'
,
'n'
,
'e'
,
'M'
,
'a'
,
'p'
,
'\\'
,
'D'
,
'o'
,
'm'
,
'a'
,
'i'
,
'n'
,
's'
,
0
};
static
inline
BOOL
is_drive_path
(
const
WCHAR
*
path
)
{
return
isalphaW
(
*
path
)
&&
*
(
path
+
1
)
==
':'
;
}
/********************************************************************
* get_string_from_reg [internal]
*
...
...
@@ -501,45 +506,37 @@ static HRESULT get_zone_from_domains(LPCWSTR url, LPCWSTR schema, DWORD *zone)
return
hres
;
}
static
HRESULT
map_
url_to_zone
(
LPCWSTR
url
,
DWORD
*
zone
,
LPWSTR
*
ret_url
)
static
HRESULT
map_
security_uri_to_zone
(
IUri
*
uri
,
DWORD
*
zone
)
{
LPWSTR
secur_url
;
WCHAR
schema
[
64
];
DWORD
size
=
0
;
HRESULT
hres
;
BSTR
scheme
;
*
zone
=
URLZONE_INVALID
;
hres
=
CoInternetGetSecurityUrl
(
url
,
&
secur_url
,
PSU_SECURITY_URL_ONLY
,
0
);
if
(
hres
!=
S_OK
)
{
size
=
strlenW
(
url
)
*
sizeof
(
WCHAR
);
secur_url
=
CoTaskMemAlloc
(
size
);
if
(
!
secur_url
)
return
E_OUTOFMEMORY
;
memcpy
(
secur_url
,
url
,
size
);
}
hres
=
IUri_GetSchemeName
(
uri
,
&
scheme
);
if
(
FAILED
(
hres
))
return
hres
;
hres
=
CoInternetParseUrl
(
secur_url
,
PARSE_SCHEMA
,
0
,
schema
,
sizeof
(
schema
)
/
sizeof
(
WCHAR
),
&
size
,
0
);
if
(
FAILED
(
hres
)
||
!*
schema
)
{
CoTaskMemFree
(
secur_url
);
return
E_INVALIDARG
;
}
if
(
!
strcmpiW
(
scheme
,
fileW
))
{
BSTR
path
;
WCHAR
*
ptr
,
*
path_start
,
root
[
20
];
/* file protocol is a special case */
if
(
!
strcmpW
(
schema
,
fileW
))
{
WCHAR
path
[
MAX_PATH
],
root
[
20
];
WCHAR
*
ptr
;
hres
=
IUri_GetPath
(
uri
,
&
path
);
if
(
FAILED
(
hres
))
{
SysFreeString
(
scheme
);
return
hres
;
}
hres
=
CoInternetParseUrl
(
secur_url
,
PARSE_PATH_FROM_URL
,
0
,
path
,
sizeof
(
path
)
/
sizeof
(
WCHAR
),
&
size
,
0
);
if
(
*
path
==
'/'
&&
is_drive_path
(
path
+
1
))
path_start
=
path
+
1
;
else
path_start
=
path
;
if
(
SUCCEEDED
(
hres
)
&&
(
ptr
=
strchrW
(
path
,
'\\'
))
&&
ptr
-
path
<
sizeof
(
root
)
/
sizeof
(
WCHAR
))
{
if
(
((
ptr
=
strchrW
(
path_start
,
'\\'
))
||
(
ptr
=
strchrW
(
path_start
,
'/'
)))
&&
ptr
-
path_start
<
sizeof
(
root
)
/
sizeof
(
WCHAR
))
{
UINT
type
;
memcpy
(
root
,
path
,
(
ptr
-
path
)
*
sizeof
(
WCHAR
));
root
[
ptr
-
path
]
=
0
;
memcpy
(
root
,
path
_start
,
(
ptr
-
path_start
)
*
sizeof
(
WCHAR
));
root
[
ptr
-
path
_start
]
=
0
;
type
=
GetDriveTypeW
(
root
);
...
...
@@ -562,14 +559,56 @@ static HRESULT map_url_to_zone(LPCWSTR url, DWORD *zone, LPWSTR *ret_url)
FIXME
(
"unsupported drive type %d
\n
"
,
type
);
}
}
SysFreeString
(
path
);
}
if
(
*
zone
==
URLZONE_INVALID
)
{
hres
=
get_zone_from_domains
(
secur_url
,
schema
,
zone
);
BSTR
secur_url
;
hres
=
IUri_GetDisplayUri
(
uri
,
&
secur_url
);
if
(
FAILED
(
hres
))
{
SysFreeString
(
scheme
);
return
hres
;
}
hres
=
get_zone_from_domains
(
secur_url
,
scheme
,
zone
);
SysFreeString
(
secur_url
);
if
(
hres
==
S_FALSE
)
hres
=
get_zone_from_reg
(
schem
a
,
zone
);
hres
=
get_zone_from_reg
(
schem
e
,
zone
);
}
SysFreeString
(
scheme
);
return
hres
;
}
static
HRESULT
map_url_to_zone
(
LPCWSTR
url
,
DWORD
*
zone
,
LPWSTR
*
ret_url
)
{
IUri
*
secur_uri
;
LPWSTR
secur_url
;
HRESULT
hres
;
*
zone
=
URLZONE_INVALID
;
hres
=
CoInternetGetSecurityUrl
(
url
,
&
secur_url
,
PSU_SECURITY_URL_ONLY
,
0
);
if
(
hres
!=
S_OK
)
{
DWORD
size
=
strlenW
(
url
)
*
sizeof
(
WCHAR
);
secur_url
=
CoTaskMemAlloc
(
size
);
if
(
!
secur_url
)
return
E_OUTOFMEMORY
;
memcpy
(
secur_url
,
url
,
size
);
}
hres
=
CreateUri
(
secur_url
,
0
,
0
,
&
secur_uri
);
if
(
FAILED
(
hres
))
{
CoTaskMemFree
(
secur_url
);
return
hres
;
}
hres
=
map_security_uri_to_zone
(
secur_uri
,
zone
);
IUri_Release
(
secur_uri
);
if
(
FAILED
(
hres
)
||
!
ret_url
)
CoTaskMemFree
(
secur_url
);
else
...
...
@@ -578,6 +617,21 @@ static HRESULT map_url_to_zone(LPCWSTR url, DWORD *zone, LPWSTR *ret_url)
return
hres
;
}
static
HRESULT
map_uri_to_zone
(
IUri
*
uri
,
DWORD
*
zone
)
{
HRESULT
hres
;
IUri
*
secur_uri
;
hres
=
CoInternetGetSecurityUrlEx
(
uri
,
&
secur_uri
,
PSU_SECURITY_URL_ONLY
,
0
);
if
(
FAILED
(
hres
))
return
hres
;
hres
=
map_security_uri_to_zone
(
secur_uri
,
zone
);
IUri_Release
(
secur_uri
);
return
hres
;
}
static
HRESULT
open_zone_key
(
HKEY
parent_key
,
DWORD
zone
,
HKEY
*
hkey
)
{
static
const
WCHAR
wszFormat
[]
=
{
'%'
,
's'
,
'%'
,
'u'
,
0
};
...
...
@@ -1033,8 +1087,21 @@ static HRESULT WINAPI SecManagerImpl_MapUrlToZoneEx2(IInternetSecurityManagerEx2
IUri
*
pUri
,
DWORD
*
pdwZone
,
DWORD
dwFlags
,
LPWSTR
*
ppwszMappedUrl
,
DWORD
*
pdwOutFlags
)
{
SecManagerImpl
*
This
=
impl_from_IInternetSecurityManagerEx2
(
iface
);
FIXME
(
"(%p)->(%p %p %08x %p %p) stub
\n
"
,
This
,
pUri
,
pdwZone
,
dwFlags
,
ppwszMappedUrl
,
pdwOutFlags
);
return
E_NOTIMPL
;
TRACE
(
"(%p)->(%p %p %08x %p %p)
\n
"
,
This
,
pUri
,
pdwZone
,
dwFlags
,
ppwszMappedUrl
,
pdwOutFlags
);
if
(
!
pdwZone
)
return
E_INVALIDARG
;
if
(
!
pUri
)
{
*
pdwZone
=
URLZONE_INVALID
;
return
E_INVALIDARG
;
}
if
(
dwFlags
)
FIXME
(
"Unsupported flags: %08x
\n
"
,
dwFlags
);
return
map_uri_to_zone
(
pUri
,
pdwZone
);
}
static
HRESULT
WINAPI
SecManagerImpl_ProcessUrlActionEx2
(
IInternetSecurityManagerEx2
*
iface
,
...
...
dlls/urlmon/tests/sec_mgr.c
View file @
98d5dfb8
...
...
@@ -1620,12 +1620,16 @@ static const struct {
DWORD
zone
;
BOOL
map_todo
;
}
sec_mgr_ex2_tests
[]
=
{
{
"res://mshtml.dll/blank.htm"
,
0
,
S_OK
,
URLZONE_LOCAL_MACHINE
,
TRUE
},
{
"index.htm"
,
Uri_CREATE_ALLOW_RELATIVE
,
0
,
URLZONE_INTERNET
,
TRUE
},
{
"file://c:
\\
Index.html"
,
0
,
0
,
URLZONE_LOCAL_MACHINE
,
TRUE
},
{
"http://www.zone3.winetest/"
,
0
,
0
,
URLZONE_INTERNET
,
TRUE
},
{
"about:blank"
,
0
,
0
,
URLZONE_INTERNET
,
TRUE
},
{
"ftp://zone3.winetest/file.test"
,
0
,
0
,
URLZONE_INTERNET
,
TRUE
}
{
"res://mshtml.dll/blank.htm"
,
0
,
S_OK
,
URLZONE_LOCAL_MACHINE
},
{
"index.htm"
,
Uri_CREATE_ALLOW_RELATIVE
,
0
,
URLZONE_INTERNET
},
{
"file://c:
\\
Index.html"
,
0
,
0
,
URLZONE_LOCAL_MACHINE
},
{
"http://www.zone3.winetest/"
,
0
,
0
,
URLZONE_INTERNET
},
{
"about:blank"
,
0
,
0
,
URLZONE_INTERNET
},
{
"ftp://zone3.winetest/file.test"
,
0
,
0
,
URLZONE_INTERNET
},
{
"/file/testing/test.test"
,
Uri_CREATE_ALLOW_RELATIVE
,
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
}
};
static
void
test_SecurityManagerEx2
(
void
)
...
...
@@ -1652,14 +1656,14 @@ static void test_SecurityManagerEx2(void)
zone
=
0xdeadbeef
;
hres
=
IInternetSecurityManagerEx2_MapUrlToZoneEx2
(
sec_mgr2
,
NULL
,
&
zone
,
0
,
NULL
,
NULL
);
todo_wine
ok
(
hres
==
E_INVALIDARG
,
"MapUrlToZoneEx2 returned %08x, expected E_INVALIDARG
\n
"
,
hres
);
todo_wine
ok
(
zone
==
URLZONE_INVALID
,
"zone was %d
\n
"
,
zone
);
ok
(
hres
==
E_INVALIDARG
,
"MapUrlToZoneEx2 returned %08x, expected E_INVALIDARG
\n
"
,
hres
);
ok
(
zone
==
URLZONE_INVALID
,
"zone was %d
\n
"
,
zone
);
hres
=
pCreateUri
(
url5
,
0
,
0
,
&
uri
);
ok
(
hres
==
S_OK
,
"CreateUri failed: %08x
\n
"
,
hres
);
hres
=
IInternetSecurityManagerEx2_MapUrlToZoneEx2
(
sec_mgr2
,
uri
,
NULL
,
0
,
NULL
,
NULL
);
todo_wine
ok
(
hres
==
E_INVALIDARG
,
"MapToUrlZoneEx2 returned %08x, expected E_INVALIDARG
\n
"
,
hres
);
ok
(
hres
==
E_INVALIDARG
,
"MapToUrlZoneEx2 returned %08x, expected E_INVALIDARG
\n
"
,
hres
);
IUri_Release
(
uri
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment