From fc543890d103d87f1a343c924278f89d953071b9 Mon Sep 17 00:00:00 2001 From: Piotr Caban Date: Sat, 8 May 2010 18:00:36 +0200 Subject: [PATCH] shlwapi: Make UrlCanonicalizeW working with long urls (>INTERNET_MAX_URL_LENGTH). --- dlls/shlwapi/url.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/dlls/shlwapi/url.c b/dlls/shlwapi/url.c index cd83b457178..28ea8188a38 100644 --- a/dlls/shlwapi/url.c +++ b/dlls/shlwapi/url.c @@ -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); -- 2.11.4.GIT