Commit a56fbf33 authored by Piotr Caban's avatar Piotr Caban Committed by Alexandre Julliard

wininet: Support Punycode in RetrieveUrlCacheEntryStream.

parent c5346085
...@@ -3154,13 +3154,9 @@ BOOL WINAPI ReadUrlCacheEntryStream( ...@@ -3154,13 +3154,9 @@ BOOL WINAPI ReadUrlCacheEntryStream(
* RetrieveUrlCacheEntryStreamA (WININET.@) * RetrieveUrlCacheEntryStreamA (WININET.@)
* *
*/ */
HANDLE WINAPI RetrieveUrlCacheEntryStreamA( HANDLE WINAPI RetrieveUrlCacheEntryStreamA(LPCSTR lpszUrlName,
IN LPCSTR lpszUrlName, LPINTERNET_CACHE_ENTRY_INFOA lpCacheEntryInfo,
OUT LPINTERNET_CACHE_ENTRY_INFOA lpCacheEntryInfo, LPDWORD lpdwCacheEntryInfoBufferSize, BOOL fRandomRead, DWORD dwReserved)
IN OUT LPDWORD lpdwCacheEntryInfoBufferSize,
IN BOOL fRandomRead,
IN DWORD dwReserved
)
{ {
/* NOTE: this is not the same as the way that the native /* NOTE: this is not the same as the way that the native
* version allocates 'stream' handles. I did it this way * version allocates 'stream' handles. I did it this way
...@@ -3168,103 +3164,89 @@ HANDLE WINAPI RetrieveUrlCacheEntryStreamA( ...@@ -3168,103 +3164,89 @@ HANDLE WINAPI RetrieveUrlCacheEntryStreamA(
* on this behaviour. (Native version appears to allocate * on this behaviour. (Native version appears to allocate
* indices into a table) * indices into a table)
*/ */
stream_handle *pStream; stream_handle *stream;
HANDLE hFile; HANDLE file;
TRACE( "(%s, %p, %p, %x, 0x%08x)\n", debugstr_a(lpszUrlName), lpCacheEntryInfo, TRACE("(%s, %p, %p, %x, 0x%08x)\n", debugstr_a(lpszUrlName), lpCacheEntryInfo,
lpdwCacheEntryInfoBufferSize, fRandomRead, dwReserved ); lpdwCacheEntryInfoBufferSize, fRandomRead, dwReserved);
if (!RetrieveUrlCacheEntryFileA(lpszUrlName, if(!RetrieveUrlCacheEntryFileA(lpszUrlName, lpCacheEntryInfo,
lpCacheEntryInfo, lpdwCacheEntryInfoBufferSize, dwReserved))
lpdwCacheEntryInfoBufferSize, return NULL;
dwReserved))
{ file = CreateFileA(lpCacheEntryInfo->lpszLocalFileName, GENERIC_READ, FILE_SHARE_READ,
NULL, OPEN_EXISTING, fRandomRead ? FILE_FLAG_RANDOM_ACCESS : 0, NULL);
if(file == INVALID_HANDLE_VALUE) {
UnlockUrlCacheEntryFileA(lpszUrlName, 0);
return NULL; return NULL;
} }
hFile = CreateFileA(lpCacheEntryInfo->lpszLocalFileName,
GENERIC_READ,
FILE_SHARE_READ,
NULL,
OPEN_EXISTING,
fRandomRead ? FILE_FLAG_RANDOM_ACCESS : 0,
NULL);
if (hFile == INVALID_HANDLE_VALUE)
return FALSE;
/* allocate handle storage space */ /* allocate handle storage space */
pStream = heap_alloc(sizeof(stream_handle) + strlen(lpszUrlName) * sizeof(CHAR)); stream = heap_alloc(sizeof(stream_handle) + strlen(lpszUrlName) * sizeof(CHAR));
if (!pStream) if(!stream) {
{ CloseHandle(file);
CloseHandle(hFile); UnlockUrlCacheEntryFileA(lpszUrlName, 0);
SetLastError(ERROR_OUTOFMEMORY); SetLastError(ERROR_OUTOFMEMORY);
return FALSE; return NULL;
} }
pStream->file = hFile; stream->file = file;
strcpy(pStream->url, lpszUrlName); strcpy(stream->url, lpszUrlName);
return pStream; return stream;
} }
/*********************************************************************** /***********************************************************************
* RetrieveUrlCacheEntryStreamW (WININET.@) * RetrieveUrlCacheEntryStreamW (WININET.@)
* *
*/ */
HANDLE WINAPI RetrieveUrlCacheEntryStreamW( HANDLE WINAPI RetrieveUrlCacheEntryStreamW(LPCWSTR lpszUrlName,
IN LPCWSTR lpszUrlName, LPINTERNET_CACHE_ENTRY_INFOW lpCacheEntryInfo,
OUT LPINTERNET_CACHE_ENTRY_INFOW lpCacheEntryInfo, LPDWORD lpdwCacheEntryInfoBufferSize, BOOL fRandomRead, DWORD dwReserved)
IN OUT LPDWORD lpdwCacheEntryInfoBufferSize,
IN BOOL fRandomRead,
IN DWORD dwReserved
)
{ {
DWORD size; DWORD len;
int url_len;
/* NOTE: this is not the same as the way that the native /* NOTE: this is not the same as the way that the native
* version allocates 'stream' handles. I did it this way * version allocates 'stream' handles. I did it this way
* as it is much easier and no applications should depend * as it is much easier and no applications should depend
* on this behaviour. (Native version appears to allocate * on this behaviour. (Native version appears to allocate
* indices into a table) * indices into a table)
*/ */
stream_handle *pStream; stream_handle *stream;
HANDLE hFile; HANDLE file;
TRACE( "(%s, %p, %p, %x, 0x%08x)\n", debugstr_w(lpszUrlName), lpCacheEntryInfo, TRACE("(%s, %p, %p, %x, 0x%08x)\n", debugstr_w(lpszUrlName), lpCacheEntryInfo,
lpdwCacheEntryInfoBufferSize, fRandomRead, dwReserved ); lpdwCacheEntryInfoBufferSize, fRandomRead, dwReserved);
if (!RetrieveUrlCacheEntryFileW(lpszUrlName, if(!(len = urlcache_encode_url(lpszUrlName, NULL, 0)))
lpCacheEntryInfo,
lpdwCacheEntryInfoBufferSize,
dwReserved))
{
return NULL; return NULL;
}
hFile = CreateFileW(lpCacheEntryInfo->lpszLocalFileName, if(!RetrieveUrlCacheEntryFileW(lpszUrlName, lpCacheEntryInfo,
GENERIC_READ, lpdwCacheEntryInfoBufferSize, dwReserved))
FILE_SHARE_READ, return NULL;
NULL,
OPEN_EXISTING, file = CreateFileW(lpCacheEntryInfo->lpszLocalFileName, GENERIC_READ, FILE_SHARE_READ,
fRandomRead ? FILE_FLAG_RANDOM_ACCESS : 0, NULL, OPEN_EXISTING, fRandomRead ? FILE_FLAG_RANDOM_ACCESS : 0, NULL);
NULL); if(file == INVALID_HANDLE_VALUE) {
if (hFile == INVALID_HANDLE_VALUE) UnlockUrlCacheEntryFileW(lpszUrlName, 0);
return FALSE; return NULL;
}
/* allocate handle storage space */ /* allocate handle storage space */
size = sizeof(stream_handle); stream = heap_alloc(sizeof(stream_handle) + len*sizeof(WCHAR));
url_len = WideCharToMultiByte(CP_ACP, 0, lpszUrlName, -1, NULL, 0, NULL, NULL); if(!stream) {
size += url_len; CloseHandle(file);
pStream = heap_alloc(size); UnlockUrlCacheEntryFileW(lpszUrlName, 0);
if (!pStream)
{
CloseHandle(hFile);
SetLastError(ERROR_OUTOFMEMORY); SetLastError(ERROR_OUTOFMEMORY);
return FALSE; return NULL;
} }
pStream->file = hFile; stream->file = file;
WideCharToMultiByte(CP_ACP, 0, lpszUrlName, -1, pStream->url, url_len, NULL, NULL); if(!urlcache_encode_url(lpszUrlName, stream->url, len)) {
return pStream; CloseHandle(file);
UnlockUrlCacheEntryFileW(lpszUrlName, 0);
heap_free(stream);
return NULL;
}
return stream;
} }
/*********************************************************************** /***********************************************************************
......
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