wininet: Avoid illegal filenames in CreateUrlCacheEntryW.

This commit is contained in:
Hans Leidekker 2009-01-19 11:40:45 +01:00 committed by Alexandre Julliard
parent 2c9a41a4e4
commit b33792235e
1 changed files with 18 additions and 1 deletions

View File

@ -2313,9 +2313,26 @@ BOOL WINAPI CreateUrlCacheEntryW(
for (i = 0; i < 255; i++)
{
static const WCHAR szFormat[] = {'[','%','u',']','%','s',0};
static const WCHAR szFormat[] = {'[','%','u',']','%','s',0};
HANDLE hFile;
WCHAR *p;
wsprintfW(lpszFileNameNoPath + countnoextension, szFormat, i, szExtension);
for (p = lpszFileNameNoPath + 1; *p; p++)
{
switch (*p)
{
case '<': case '>':
case ':': case '"':
case '/': case '\\':
case '|': case '?':
case '*':
*p = '_'; break;
default: break;
}
}
if (p[-1] == ' ' || p[-1] == '.') p[-1] = '_';
TRACE("Trying: %s\n", debugstr_w(lpszFileName));
hFile = CreateFileW(lpszFileName, GENERIC_READ, 0, NULL, CREATE_NEW, 0, NULL);
if (hFile != INVALID_HANDLE_VALUE)