shlwapi: Make UrlCanonicalizeW working with long urls (>INTERNET_MAX_URL_LENGTH).

This commit is contained in:
Piotr Caban 2010-05-08 18:00:36 +02:00 committed by Alexandre Julliard
parent f4f9b1acdf
commit fc543890d1
1 changed files with 6 additions and 4 deletions

View File

@ -287,11 +287,12 @@ HRESULT WINAPI UrlCanonicalizeW(LPCWSTR pszUrl, LPWSTR pszCanonicalized,
static const WCHAR wszFile[] = {'f','i','l','e',':'};
static const WCHAR wszRes[] = {'r','e','s',':'};
static const WCHAR wszLocalhost[] = {'l','o','c','a','l','h','o','s','t'};
static const WCHAR wszFilePrefix[] = {'f','i','l','e',':','/','/','/'};
TRACE("(%s, %p, %p, 0x%08x) *pcchCanonicalized: %d\n", debugstr_w(pszUrl), pszCanonicalized,
pcchCanonicalized, dwFlags, pcchCanonicalized ? *pcchCanonicalized : -1);
if(!pszUrl || !pszCanonicalized || !pcchCanonicalized)
if(!pszUrl || !pszCanonicalized || !pcchCanonicalized || !*pcchCanonicalized)
return E_INVALIDARG;
if(!*pszUrl) {
@ -300,8 +301,9 @@ HRESULT WINAPI UrlCanonicalizeW(LPCWSTR pszUrl, LPWSTR pszCanonicalized,
}
nByteLen = (strlenW(pszUrl) + 1) * sizeof(WCHAR); /* length in bytes */
/* Allocate memory for simplified URL (before escaping) */
lpszUrlCpy = HeapAlloc(GetProcessHeap(), 0,
INTERNET_MAX_URL_LENGTH * sizeof(WCHAR));
nByteLen+sizeof(wszFilePrefix)+sizeof(WCHAR));
if((dwFlags & URL_FILE_USE_PATHURL) && nByteLen >= sizeof(wszFile)
&& !memcmp(wszFile, pszUrl, sizeof(wszFile)))
@ -328,8 +330,6 @@ HRESULT WINAPI UrlCanonicalizeW(LPCWSTR pszUrl, LPWSTR pszCanonicalized,
state = 0;
if(pszUrl[1] == ':') { /* Assume path */
static const WCHAR wszFilePrefix[] = {'f','i','l','e',':','/','/','/'};
memcpy(wk2, wszFilePrefix, sizeof(wszFilePrefix));
wk2 += sizeof(wszFilePrefix)/sizeof(WCHAR);
if (dwFlags & URL_FILE_USE_PATHURL)
@ -833,6 +833,8 @@ HRESULT WINAPI UrlCombineW(LPCWSTR pszBase, LPCWSTR pszRelative,
if (ret == S_OK) {
/* Reuse mrelative as temp storage as its already allocated and not needed anymore */
if(*pcchCombined == 0)
*pcchCombined = 1;
ret = UrlCanonicalizeW(preliminary, mrelative, pcchCombined, (dwFlags & ~URL_FILE_USE_PATHURL));
if(SUCCEEDED(ret) && pszCombined) {
lstrcpyW(pszCombined, mrelative);