Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
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-cw
Commits
940176d8
Commit
940176d8
authored
Apr 01, 2013
by
Piotr Caban
Committed by
Alexandre Julliard
Apr 01, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wininet: Support Punycode in GetUrlCacheEntryInfoExW.
parent
c3a23a99
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
157 additions
and
179 deletions
+157
-179
urlcache.c
dlls/wininet/urlcache.c
+157
-179
No files found.
dlls/wininet/urlcache.c
View file @
940176d8
...
...
@@ -1742,254 +1742,232 @@ static BOOL urlcache_hash_entry_is_locked(struct hash_entry *hash_entry, entry_u
return
TRUE
;
}
/***********************************************************************
* GetUrlCacheEntryInfoExA (WININET.@)
*
*/
BOOL
WINAPI
GetUrlCacheEntryInfoExA
(
LPCSTR
lpszUrl
,
LPINTERNET_CACHE_ENTRY_INFOA
lpCacheEntryInfo
,
LPDWORD
lpdwCacheEntryInfoBufSize
,
LPSTR
lpszReserved
,
LPDWORD
lpdwReserved
,
LPVOID
lpReserved
,
DWORD
dwFlags
)
BOOL
urlcache_get_entry_info
(
const
char
*
url
,
void
*
entry_info
,
DWORD
*
size
,
DWORD
flags
,
BOOL
unicode
)
{
urlcache_header
*
pHeader
;
struct
hash_entry
*
pHashEntry
;
const
entry_header
*
pEntry
;
const
entry_url
*
pUrlEntry
;
cache_container
*
pContainer
;
urlcache_header
*
header
;
struct
hash_entry
*
hash_entry
;
const
entry_url
*
url_entry
;
cache_container
*
container
;
DWORD
error
;
TRACE
(
"(%s, %p, %p, %p, %p, %p, %x)
\n
"
,
debugstr_a
(
lpszUrl
),
lpCacheEntryInfo
,
lpdwCacheEntryInfoBufSize
,
lpszReserved
,
lpdwReserved
,
lpReserved
,
dwFlags
);
TRACE
(
"(%s, %p, %p, %x, %x)
\n
"
,
debugstr_a
(
url
),
entry_info
,
size
,
flags
,
unicode
);
if
((
lpszReserved
!=
NULL
)
||
(
lpdwReserved
!=
NULL
)
||
(
lpReserved
!=
NULL
))
{
ERR
(
"Reserved value was not 0
\n
"
);
SetLastError
(
ERROR_INVALID_PARAMETER
);
return
FALSE
;
}
if
(
dwFlags
&
~
GET_INSTALLED_ENTRY
)
FIXME
(
"ignoring unsupported flags: %x
\n
"
,
dwFlags
);
if
(
flags
&
~
GET_INSTALLED_ENTRY
)
FIXME
(
"ignoring unsupported flags: %x
\n
"
,
flags
);
error
=
cache_containers_find
(
lpszUrl
,
&
pContainer
);
if
(
error
!=
ERROR_SUCCESS
)
{
error
=
cache_containers_find
(
url
,
&
container
);
if
(
error
!=
ERROR_SUCCESS
)
{
SetLastError
(
error
);
return
FALSE
;
}
error
=
cache_container_open_index
(
pContainer
,
MIN_BLOCK_NO
);
if
(
error
!=
ERROR_SUCCESS
)
{
error
=
cache_container_open_index
(
container
,
MIN_BLOCK_NO
);
if
(
error
!=
ERROR_SUCCESS
)
{
SetLastError
(
error
);
return
FALSE
;
}
if
(
!
(
pHeader
=
cache_container_lock_index
(
pC
ontainer
)))
if
(
!
(
header
=
cache_container_lock_index
(
c
ontainer
)))
return
FALSE
;
if
(
!
urlcache_find_hash_entry
(
pHeader
,
lpszUrl
,
&
pHashEntry
))
{
cache_container_unlock_index
(
pContainer
,
pHeader
);
WARN
(
"entry %s not found!
\n
"
,
debugstr_a
(
lpszUrl
));
if
(
!
urlcache_find_hash_entry
(
header
,
url
,
&
hash_entry
))
{
cache_container_unlock_index
(
container
,
header
);
WARN
(
"entry %s not found!
\n
"
,
debugstr_a
(
url
));
SetLastError
(
ERROR_FILE_NOT_FOUND
);
return
FALSE
;
}
pEntry
=
(
const
entry_header
*
)((
LPBYTE
)
pHeader
+
pHashEntry
->
offset
);
if
(
pEntry
->
signature
!=
URL_SIGNATURE
)
{
cache_container_unlock_index
(
pContainer
,
pHeader
);
url_entry
=
(
const
entry_url
*
)((
LPBYTE
)
header
+
hash_entry
->
offset
);
if
(
url_entry
->
header
.
signature
!=
URL_SIGNATURE
)
{
cache_container_unlock_index
(
container
,
header
);
FIXME
(
"Trying to retrieve entry of unknown format %s
\n
"
,
debugstr_an
((
LPCSTR
)
&
pEntry
->
signature
,
sizeof
(
DWORD
)));
debugstr_an
((
LPCSTR
)
&
url_entry
->
header
.
signature
,
sizeof
(
DWORD
)));
SetLastError
(
ERROR_FILE_NOT_FOUND
);
return
FALSE
;
}
pUrlEntry
=
(
const
entry_url
*
)
pEntry
;
TRACE
(
"Found URL: %s
\n
"
,
debugstr_a
((
LPCSTR
)
pUrlEntry
+
pUrlEntry
->
url_off
));
TRACE
(
"Header info: %s
\n
"
,
debugstr_an
((
LPCSTR
)
pUrlEntry
+
pUrlEntry
->
header_info_off
,
pUrlEntry
->
header_info_size
));
TRACE
(
"Found URL: %s
\n
"
,
debugstr_a
((
LPCSTR
)
url_entry
+
url_entry
->
url_off
));
TRACE
(
"Header info: %s
\n
"
,
debugstr_an
((
LPCSTR
)
url_entry
+
url_entry
->
header_info_off
,
url_entry
->
header_info_size
));
if
((
dwFlags
&
GET_INSTALLED_ENTRY
)
&&
!
(
pUrlEntry
->
cache_entry_type
&
INSTALLED_CACHE_ENTRY
))
{
cache_container_unlock_index
(
pContainer
,
pHeader
);
if
((
flags
&
GET_INSTALLED_ENTRY
)
&&
!
(
url_entry
->
cache_entry_type
&
INSTALLED_CACHE_ENTRY
))
{
cache_container_unlock_index
(
container
,
header
);
SetLastError
(
ERROR_FILE_NOT_FOUND
);
return
FALSE
;
}
if
(
lpdwCacheEntryInfoBufSize
)
{
if
(
!
lpCacheEntryInfo
)
*
lpdwCacheEntryInfoBufSize
=
0
;
if
(
size
)
{
if
(
!
entry_info
)
*
size
=
0
;
error
=
urlcache_copy_entry
(
pContainer
,
pHeader
,
lpCacheEntryInfo
,
lpdwCacheEntryInfoBufSize
,
pUrlEntry
,
FALSE
/* ANSI */
);
if
(
error
!=
ERROR_SUCCESS
)
{
cache_container_unlock_index
(
pContainer
,
pHeader
);
error
=
urlcache_copy_entry
(
container
,
header
,
entry_info
,
size
,
url_entry
,
unicode
);
if
(
error
!=
ERROR_SUCCESS
)
{
cache_container_unlock_index
(
container
,
header
);
SetLastError
(
error
);
return
FALSE
;
}
if
(
pUrlE
ntry
->
local_name_off
)
TRACE
(
"Local File Name: %s
\n
"
,
debugstr_a
((
LPCSTR
)
pUrlEntry
+
pUrlE
ntry
->
local_name_off
));
if
(
url_e
ntry
->
local_name_off
)
TRACE
(
"Local File Name: %s
\n
"
,
debugstr_a
((
LPCSTR
)
url_entry
+
url_e
ntry
->
local_name_off
));
}
cache_container_unlock_index
(
pContainer
,
pHeader
);
cache_container_unlock_index
(
container
,
header
);
return
TRUE
;
}
/***********************************************************************
* GetUrlCacheEntryInfoA (WININET.@)
* GetUrlCacheEntryInfo
Ex
A (WININET.@)
*
*/
BOOL
WINAPI
GetUrlCacheEntryInfoA
(
IN
LPCSTR
lpszUrlName
,
IN
LPINTERNET_CACHE_ENTRY_INFOA
lpCacheEntryInfo
,
IN
OUT
LPDWORD
lpdwCacheEntryInfoBufferSize
)
BOOL
WINAPI
GetUrlCacheEntryInfoExA
(
LPCSTR
lpszUrl
,
LPINTERNET_CACHE_ENTRY_INFOA
lpCacheEntryInfo
,
LPDWORD
lpdwCacheEntryInfoBufSize
,
LPSTR
lpszReserved
,
LPDWORD
lpdwReserved
,
LPVOID
lpReserved
,
DWORD
dwFlags
)
{
return
GetUrlCacheEntryInfoExA
(
lpszUrlName
,
lpCacheEntryInfo
,
lpdwCacheEntryInfoBufferSize
,
NULL
,
NULL
,
NULL
,
0
);
if
(
lpszReserved
!=
NULL
||
lpdwReserved
!=
NULL
||
lpReserved
!=
NULL
)
{
ERR
(
"Reserved value was not 0
\n
"
);
SetLastError
(
ERROR_INVALID_PARAMETER
);
return
FALSE
;
}
return
urlcache_get_entry_info
(
lpszUrl
,
lpCacheEntryInfo
,
lpdwCacheEntryInfoBufSize
,
dwFlags
,
FALSE
);
}
/***********************************************************************
* GetUrlCacheEntryInfo
W
(WININET.@)
* GetUrlCacheEntryInfo
A
(WININET.@)
*
*/
BOOL
WINAPI
GetUrlCacheEntryInfo
W
(
LPCWSTR
lpszUrl
,
LPINTERNET_CACHE_ENTRY_INFOW
lpCacheEntryInfo
,
LPDWORD
lpdwCacheEntryInfoBufferSize
)
BOOL
WINAPI
GetUrlCacheEntryInfo
A
(
LPCSTR
lpszUrlName
,
LPINTERNET_CACHE_ENTRY_INFOA
lpCacheEntryInfo
,
LPDWORD
lpdwCacheEntryInfoBufferSize
)
{
return
GetUrlCacheEntryInfoEx
W
(
lpszUrl
,
lpCacheEntryInfo
,
return
GetUrlCacheEntryInfoEx
A
(
lpszUrlName
,
lpCacheEntryInfo
,
lpdwCacheEntryInfoBufferSize
,
NULL
,
NULL
,
NULL
,
0
);
}
/***********************************************************************
* GetUrlCacheEntryInfoExW (WININET.@)
*
*/
BOOL
WINAPI
GetUrlCacheEntryInfoExW
(
LPCWSTR
lpszUrl
,
LPINTERNET_CACHE_ENTRY_INFOW
lpCacheEntryInfo
,
LPDWORD
lpdwCacheEntryInfoBufSize
,
LPWSTR
lpszReserved
,
LPDWORD
lpdwReserved
,
LPVOID
lpReserved
,
DWORD
dwFlags
)
static
int
urlcache_encode_url
(
const
WCHAR
*
url
,
char
*
encoded_url
,
int
encoded_len
)
{
urlcache_header
*
pHeader
;
struct
hash_entry
*
pHashEntry
;
const
entry_header
*
pEntry
;
const
entry_url
*
pUrlEntry
;
cache_container
*
pContainer
;
DWORD
error
;
TRACE
(
"(%s, %p, %p, %p, %p, %p, %x)
\n
"
,
debugstr_w
(
lpszUrl
),
lpCacheEntryInfo
,
lpdwCacheEntryInfoBufSize
,
lpszReserved
,
lpdwReserved
,
lpReserved
,
dwFlags
);
URL_COMPONENTSW
uc
;
DWORD
len
,
part_len
;
WCHAR
*
punycode
;
TRACE
(
"%s
\n
"
,
debugstr_w
(
url
));
memset
(
&
uc
,
0
,
sizeof
(
uc
));
uc
.
dwStructSize
=
sizeof
(
uc
);
uc
.
dwHostNameLength
=
1
;
if
(
!
InternetCrackUrlW
(
url
,
0
,
0
,
&
uc
))
uc
.
nScheme
=
INTERNET_SCHEME_UNKNOWN
;
if
(
uc
.
nScheme
!=
INTERNET_SCHEME_HTTP
&&
uc
.
nScheme
!=
INTERNET_SCHEME_HTTPS
)
return
WideCharToMultiByte
(
CP_UTF8
,
0
,
url
,
-
1
,
encoded_url
,
encoded_len
,
NULL
,
NULL
);
len
=
WideCharToMultiByte
(
CP_UTF8
,
0
,
url
,
uc
.
lpszHostName
-
url
,
encoded_url
,
encoded_len
,
NULL
,
NULL
);
if
(
!
len
)
return
0
;
if
(
encoded_url
)
encoded_len
-=
len
;
part_len
=
IdnToAscii
(
0
,
uc
.
lpszHostName
,
uc
.
dwHostNameLength
,
NULL
,
0
);
if
(
!
part_len
)
{
SetLastError
(
ERROR_INTERNET_INVALID_URL
);
return
0
;
}
punycode
=
heap_alloc
(
part_len
*
sizeof
(
WCHAR
));
if
(
!
punycode
)
return
0
;
part_len
=
IdnToAscii
(
0
,
uc
.
lpszHostName
,
uc
.
dwHostNameLength
,
punycode
,
part_len
);
if
(
!
part_len
)
{
heap_free
(
punycode
);
return
0
;
}
part_len
=
WideCharToMultiByte
(
CP_UTF8
,
0
,
punycode
,
part_len
,
encoded_url
?
encoded_url
+
len
:
NULL
,
encoded_len
,
NULL
,
NULL
);
heap_free
(
punycode
);
if
(
!
part_len
)
return
0
;
if
(
encoded_url
)
encoded_len
-=
part_len
;
len
+=
part_len
;
part_len
=
WideCharToMultiByte
(
CP_UTF8
,
0
,
uc
.
lpszHostName
+
uc
.
dwHostNameLength
,
-
1
,
encoded_url
?
encoded_url
+
len
:
NULL
,
encoded_len
,
NULL
,
NULL
);
if
(
!
part_len
)
return
0
;
len
+=
part_len
;
TRACE
(
"got (%d)%s
\n
"
,
len
,
debugstr_a
(
encoded_url
));
return
len
;
}
/* Ignore GET_INSTALLED_ENTRY flag in unicode version of function */
dwFlags
&=
~
GET_INSTALLED_ENTRY
;
static
BOOL
urlcache_encode_url_alloc
(
const
WCHAR
*
url
,
char
**
encoded_url
)
{
DWORD
encoded_len
;
char
*
ret
;
if
((
lpszReserved
!=
NULL
)
||
(
lpdwReserved
!=
NULL
)
||
(
lpReserved
!=
NULL
))
{
ERR
(
"Reserved value was not 0
\n
"
);
SetLastError
(
ERROR_INVALID_PARAMETER
);
encoded_len
=
urlcache_encode_url
(
url
,
NULL
,
0
);
if
(
!
encoded_len
)
return
FALSE
;
}
if
(
dwFlags
)
FIXME
(
"ignoring unsupported flags: %x
\n
"
,
dwFlags
);
error
=
cache_containers_findW
(
lpszUrl
,
&
pContainer
);
if
(
error
!=
ERROR_SUCCESS
)
{
SetLastError
(
error
);
ret
=
heap_alloc
(
encoded_len
*
sizeof
(
WCHAR
));
if
(
!
ret
)
return
FALSE
;
}
error
=
cache_container_open_index
(
pContainer
,
MIN_BLOCK_NO
);
if
(
error
!=
ERROR_SUCCESS
)
{
SetLastError
(
error
);
encoded_len
=
urlcache_encode_url
(
url
,
ret
,
encoded_len
);
if
(
!
encoded_len
)
{
heap_free
(
ret
);
return
FALSE
;
}
if
(
!
(
pHeader
=
cache_container_lock_index
(
pContainer
)))
return
FALSE
;
*
encoded_url
=
ret
;
return
TRUE
;
}
if
(
!
urlcache_find_hash_entryW
(
pHeader
,
lpszUrl
,
&
pHashEntry
))
{
cache_container_unlock_index
(
pContainer
,
pHeader
);
WARN
(
"entry %s not found!
\n
"
,
debugstr_w
(
lpszUrl
));
SetLastError
(
ERROR_FILE_NOT_FOUND
);
return
FALSE
;
}
/***********************************************************************
* GetUrlCacheEntryInfoExW (WININET.@)
*
*/
BOOL
WINAPI
GetUrlCacheEntryInfoExW
(
LPCWSTR
lpszUrl
,
LPINTERNET_CACHE_ENTRY_INFOW
lpCacheEntryInfo
,
LPDWORD
lpdwCacheEntryInfoBufSize
,
LPWSTR
lpszReserved
,
LPDWORD
lpdwReserved
,
LPVOID
lpReserved
,
DWORD
dwFlags
)
{
char
*
url
;
BOOL
ret
;
pEntry
=
(
const
entry_header
*
)((
LPBYTE
)
pHeader
+
pHashEntry
->
offset
);
if
(
pEntry
->
signature
!=
URL_SIGNATURE
)
{
cache_container_unlock_index
(
pContainer
,
pHeader
);
FIXME
(
"Trying to retrieve entry of unknown format %s
\n
"
,
debugstr_an
((
LPCSTR
)
&
pEntry
->
signature
,
sizeof
(
DWORD
)));
SetLastError
(
ERROR_FILE_NOT_FOUND
);
if
(
lpszReserved
!=
NULL
||
lpdwReserved
!=
NULL
||
lpReserved
!=
NULL
)
{
ERR
(
"Reserved value was not 0
\n
"
);
SetLastError
(
ERROR_INVALID_PARAMETER
);
return
FALSE
;
}
pUrlEntry
=
(
const
entry_url
*
)
pEntry
;
TRACE
(
"Found URL: %s
\n
"
,
debugstr_a
((
LPCSTR
)
pUrlEntry
+
pUrlEntry
->
url_off
));
TRACE
(
"Header info: %s
\n
"
,
debugstr_an
((
LPCSTR
)
pUrlEntry
+
pUrlEntry
->
header_info_off
,
pUrlEntry
->
header_info_size
));
if
(
lpdwCacheEntryInfoBufSize
)
{
if
(
!
lpCacheEntryInfo
)
*
lpdwCacheEntryInfoBufSize
=
0
;
/* Ignore GET_INSTALLED_ENTRY flag in unicode version of function */
dwFlags
&=
~
GET_INSTALLED_ENTRY
;
error
=
urlcache_copy_entry
(
pContainer
,
pHeader
,
(
LPINTERNET_CACHE_ENTRY_INFOA
)
lpCacheEntryInfo
,
lpdwCacheEntryInfoBufSize
,
pUrlEntry
,
TRUE
/* UNICODE */
);
if
(
error
!=
ERROR_SUCCESS
)
{
cache_container_unlock_index
(
pContainer
,
pHeader
);
SetLastError
(
error
);
return
FALSE
;
}
if
(
pUrlEntry
->
local_name_off
)
TRACE
(
"Local File Name: %s
\n
"
,
debugstr_a
((
LPCSTR
)
pUrlEntry
+
pUrlEntry
->
local_name_off
));
}
if
(
!
urlcache_encode_url_alloc
(
lpszUrl
,
&
url
))
return
FALSE
;
cache_container_unlock_index
(
pContainer
,
pHeader
);
ret
=
urlcache_get_entry_info
(
url
,
lpCacheEntryInfo
,
lpdwCacheEntryInfoBufSize
,
dwFlags
,
TRUE
);
heap_free
(
url
);
return
ret
;
}
return
TRUE
;
/***********************************************************************
* GetUrlCacheEntryInfoW (WININET.@)
*
*/
BOOL
WINAPI
GetUrlCacheEntryInfoW
(
LPCWSTR
lpszUrl
,
LPINTERNET_CACHE_ENTRY_INFOW
lpCacheEntryInfo
,
LPDWORD
lpdwCacheEntryInfoBufferSize
)
{
return
GetUrlCacheEntryInfoExW
(
lpszUrl
,
lpCacheEntryInfo
,
lpdwCacheEntryInfoBufferSize
,
NULL
,
NULL
,
NULL
,
0
);
}
/***********************************************************************
...
...
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