Commit 5d1b0d89 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

shlwapi: Change file path to URL in UrlCanonicalize.

parent 5674260b
...@@ -77,6 +77,11 @@ const TEST_URL_CANONICALIZE TEST_CANONICALIZE[] = { ...@@ -77,6 +77,11 @@ const TEST_URL_CANONICALIZE TEST_CANONICALIZE[] = {
{"file:///c:\\tests\\foo bar", URL_DONT_SIMPLIFY, S_OK, "file:///c:/tests/foo bar"}, {"file:///c:\\tests\\foo bar", URL_DONT_SIMPLIFY, S_OK, "file:///c:/tests/foo bar"},
{"http://www.winehq.org/site/about", URL_FILE_USE_PATHURL, S_OK, "http://www.winehq.org/site/about"}, {"http://www.winehq.org/site/about", URL_FILE_USE_PATHURL, S_OK, "http://www.winehq.org/site/about"},
{"file_://www.winehq.org/site/about", URL_FILE_USE_PATHURL, S_OK, "file_://www.winehq.org/site/about"}, {"file_://www.winehq.org/site/about", URL_FILE_USE_PATHURL, S_OK, "file_://www.winehq.org/site/about"},
{"c:\\dir\\file", 0, S_OK, "file:///c:/dir/file"},
{"file:///c:\\dir\\file", 0, S_OK, "file:///c:/dir/file"},
{"c:dir\\file", 0, S_OK, "file:///c:dir/file"},
{"A", 0, S_OK, "A"},
{"", 0, S_OK, ""}
}; };
typedef struct _TEST_URL_ESCAPE { typedef struct _TEST_URL_ESCAPE {
...@@ -429,7 +434,7 @@ static void test_url_canonicalize(const char *szUrl, DWORD dwFlags, HRESULT dwEx ...@@ -429,7 +434,7 @@ static void test_url_canonicalize(const char *szUrl, DWORD dwFlags, HRESULT dwEx
dwSize = INTERNET_MAX_URL_LENGTH; dwSize = INTERNET_MAX_URL_LENGTH;
ok(UrlCanonicalizeA(szUrl, NULL, &dwSize, dwFlags) != dwExpectReturn, "Unexpected return for NULL buffer\n"); ok(UrlCanonicalizeA(szUrl, NULL, &dwSize, dwFlags) != dwExpectReturn, "Unexpected return for NULL buffer\n");
ok(UrlCanonicalizeA(szUrl, szReturnUrl, &dwSize, dwFlags) == dwExpectReturn, "UrlCanonicalizeA didn't return 0x%08lx\n", dwExpectReturn); ok(UrlCanonicalizeA(szUrl, szReturnUrl, &dwSize, dwFlags) == dwExpectReturn, "UrlCanonicalizeA didn't return 0x%08lx\n", dwExpectReturn);
ok(strcmp(szReturnUrl,szExpectUrl)==0, "UrlCanonicalizeA dwFlags 0x%08lx Expected %s, but got %s\n", dwFlags, szExpectUrl, szReturnUrl); ok(strcmp(szReturnUrl,szExpectUrl)==0, "UrlCanonicalizeA dwFlags 0x%08lx Expected \"%s\", but got \"%s\"\n", dwFlags, szExpectUrl, szReturnUrl);
dwSize = INTERNET_MAX_URL_LENGTH; dwSize = INTERNET_MAX_URL_LENGTH;
ok(UrlCanonicalizeW(wszUrl, NULL, &dwSize, dwFlags) != dwExpectReturn, "Unexpected return for NULL buffer\n"); ok(UrlCanonicalizeW(wszUrl, NULL, &dwSize, dwFlags) != dwExpectReturn, "Unexpected return for NULL buffer\n");
......
...@@ -340,8 +340,13 @@ HRESULT WINAPI UrlCanonicalizeW(LPCWSTR pszUrl, LPWSTR pszCanonicalized, ...@@ -340,8 +340,13 @@ HRESULT WINAPI UrlCanonicalizeW(LPCWSTR pszUrl, LPWSTR pszCanonicalized,
if(!pszUrl || !pszCanonicalized || !pcchCanonicalized) if(!pszUrl || !pszCanonicalized || !pcchCanonicalized)
return E_INVALIDARG; return E_INVALIDARG;
if(!*pszUrl) {
*pszCanonicalized = 0;
return S_OK;
}
nByteLen = (lstrlenW(pszUrl) + 1) * sizeof(WCHAR); /* length in bytes */ nByteLen = (lstrlenW(pszUrl) + 1) * sizeof(WCHAR); /* length in bytes */
lpszUrlCpy = HeapAlloc(GetProcessHeap(), 0, nByteLen); lpszUrlCpy = HeapAlloc(GetProcessHeap(), 0, INTERNET_MAX_URL_LENGTH);
if((dwFlags & URL_FILE_USE_PATHURL) && nByteLen >= sizeof(wszFile) if((dwFlags & URL_FILE_USE_PATHURL) && nByteLen >= sizeof(wszFile)
&& !memcmp(wszFile, pszUrl, sizeof(wszFile))) && !memcmp(wszFile, pszUrl, sizeof(wszFile)))
...@@ -361,6 +366,15 @@ HRESULT WINAPI UrlCanonicalizeW(LPCWSTR pszUrl, LPWSTR pszCanonicalized, ...@@ -361,6 +366,15 @@ HRESULT WINAPI UrlCanonicalizeW(LPCWSTR pszUrl, LPWSTR pszCanonicalized,
wk1 = (LPWSTR)pszUrl; wk1 = (LPWSTR)pszUrl;
wk2 = lpszUrlCpy; wk2 = lpszUrlCpy;
state = 0; 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);
state = 5;
}
while (*wk1) { while (*wk1) {
switch (state) { switch (state) {
case 0: case 0:
......
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