shlwapi: UrlCanonicalize: fix URL_DONT_SIMPLIFY.
- URL_DONT_SIMPLIFY should change '/' <-> '\' - Better '/' / '\' handling
This commit is contained in:
parent
50c64c04df
commit
11a0c8cd39
|
@ -72,7 +72,9 @@ const TEST_URL_CANONICALIZE TEST_CANONICALIZE[] = {
|
||||||
{"file://c:/tests/../tests/foo%20bar", URL_FILE_USE_PATHURL, S_OK, "file://c:\\tests\\foo bar"},
|
{"file://c:/tests/../tests/foo%20bar", URL_FILE_USE_PATHURL, S_OK, "file://c:\\tests\\foo bar"},
|
||||||
{"file://c:/tests\\../tests/foo%20bar", URL_FILE_USE_PATHURL, S_OK, "file://c:\\tests\\foo bar"},
|
{"file://c:/tests\\../tests/foo%20bar", URL_FILE_USE_PATHURL, S_OK, "file://c:\\tests\\foo bar"},
|
||||||
{"file://c:/tests/foo%20bar", URL_FILE_USE_PATHURL, S_OK, "file://c:\\tests\\foo bar"},
|
{"file://c:/tests/foo%20bar", URL_FILE_USE_PATHURL, S_OK, "file://c:\\tests\\foo bar"},
|
||||||
{"file:///c://tests/foo%20bar", URL_FILE_USE_PATHURL, S_OK, "file://c:\\\\tests\\foo bar"}
|
{"file:///c://tests/foo%20bar", URL_FILE_USE_PATHURL, S_OK, "file://c:\\\\tests\\foo bar"},
|
||||||
|
{"file:///c:\\tests\\foo bar", 0, S_OK, "file:///c:/tests/foo bar"},
|
||||||
|
{"file:///c:\\tests\\foo bar", URL_DONT_SIMPLIFY, S_OK, "file:///c:/tests/foo bar"},
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct _TEST_URL_ESCAPE {
|
typedef struct _TEST_URL_ESCAPE {
|
||||||
|
@ -174,8 +176,10 @@ typedef struct _TEST_URL_COMBINE {
|
||||||
|
|
||||||
const TEST_URL_COMBINE TEST_COMBINE[] = {
|
const TEST_URL_COMBINE TEST_COMBINE[] = {
|
||||||
{"http://www.winehq.org/tests", "tests1", 0, S_OK, "http://www.winehq.org/tests1"},
|
{"http://www.winehq.org/tests", "tests1", 0, S_OK, "http://www.winehq.org/tests1"},
|
||||||
|
{"http://www.%77inehq.org/tests", "tests1", 0, S_OK, "http://www.%77inehq.org/tests1"},
|
||||||
/*FIXME {"http://www.winehq.org/tests", "../tests2", 0, S_OK, "http://www.winehq.org/tests2"},*/
|
/*FIXME {"http://www.winehq.org/tests", "../tests2", 0, S_OK, "http://www.winehq.org/tests2"},*/
|
||||||
{"http://www.winehq.org/tests/", "../tests3", 0, S_OK, "http://www.winehq.org/tests3"},
|
{"http://www.winehq.org/tests/", "../tests3", 0, S_OK, "http://www.winehq.org/tests3"},
|
||||||
|
{"http://www.winehq.org/tests/test1", "test2", 0, S_OK, "http://www.winehq.org/tests/test2"},
|
||||||
{"http://www.winehq.org/tests/../tests", "tests4", 0, S_OK, "http://www.winehq.org/tests4"},
|
{"http://www.winehq.org/tests/../tests", "tests4", 0, S_OK, "http://www.winehq.org/tests4"},
|
||||||
{"http://www.winehq.org/tests/../tests/", "tests5", 0, S_OK, "http://www.winehq.org/tests/tests5"},
|
{"http://www.winehq.org/tests/../tests/", "tests5", 0, S_OK, "http://www.winehq.org/tests/tests5"},
|
||||||
{"http://www.winehq.org/tests/../tests/", "/tests6/..", 0, S_OK, "http://www.winehq.org/"},
|
{"http://www.winehq.org/tests/../tests/", "/tests6/..", 0, S_OK, "http://www.winehq.org/"},
|
||||||
|
@ -184,6 +188,7 @@ const TEST_URL_COMBINE TEST_COMBINE[] = {
|
||||||
{"http://www.winehq.org/tests/#example", "tests9", 0, S_OK, "http://www.winehq.org/tests/tests9"},
|
{"http://www.winehq.org/tests/#example", "tests9", 0, S_OK, "http://www.winehq.org/tests/tests9"},
|
||||||
{"http://www.winehq.org/tests/../tests/", "/tests10/..", URL_DONT_SIMPLIFY, S_OK, "http://www.winehq.org/tests10/.."},
|
{"http://www.winehq.org/tests/../tests/", "/tests10/..", URL_DONT_SIMPLIFY, S_OK, "http://www.winehq.org/tests10/.."},
|
||||||
{"http://www.winehq.org/tests/../", "tests11", URL_DONT_SIMPLIFY, S_OK, "http://www.winehq.org/tests/../tests11"},
|
{"http://www.winehq.org/tests/../", "tests11", URL_DONT_SIMPLIFY, S_OK, "http://www.winehq.org/tests/../tests11"},
|
||||||
|
{"file:///C:\\dir\\file.txt", "test.txt", 0, S_OK, "file:///C:/dir/test.txt"}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
|
|
|
@ -341,10 +341,6 @@ HRESULT WINAPI UrlCanonicalizeW(LPCWSTR pszUrl, LPWSTR pszCanonicalized,
|
||||||
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, nByteLen);
|
||||||
|
|
||||||
if (dwFlags & URL_DONT_SIMPLIFY)
|
|
||||||
memcpy(lpszUrlCpy, pszUrl, nByteLen);
|
|
||||||
else {
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* state =
|
* state =
|
||||||
* 0 initial 1,3
|
* 0 initial 1,3
|
||||||
|
@ -377,7 +373,7 @@ HRESULT WINAPI UrlCanonicalizeW(LPCWSTR pszUrl, LPWSTR pszCanonicalized,
|
||||||
*wk2++ = *wk1++;
|
*wk2++ = *wk1++;
|
||||||
if (*wk1 != L'/') {state = 6; break;}
|
if (*wk1 != L'/') {state = 6; break;}
|
||||||
*wk2++ = *wk1++;
|
*wk2++ = *wk1++;
|
||||||
if((dwFlags & URL_FILE_USE_PATHURL) && *wk1 == '/')
|
if(*wk1 == '/' && (dwFlags & URL_FILE_USE_PATHURL))
|
||||||
wk1++;
|
wk1++;
|
||||||
state = 4;
|
state = 4;
|
||||||
break;
|
break;
|
||||||
|
@ -403,22 +399,26 @@ HRESULT WINAPI UrlCanonicalizeW(LPCWSTR pszUrl, LPWSTR pszCanonicalized,
|
||||||
break;
|
break;
|
||||||
case 5:
|
case 5:
|
||||||
if (*wk1 != '/' && *wk1 != '\\') {state = 3; break;}
|
if (*wk1 != '/' && *wk1 != '\\') {state = 3; break;}
|
||||||
while(*wk1 == '/') {
|
while(*wk1 == '/' || *wk1 == '\\') {
|
||||||
*wk2++ = slash;
|
*wk2++ = slash;
|
||||||
wk1++;
|
wk1++;
|
||||||
}
|
}
|
||||||
state = 6;
|
state = 6;
|
||||||
break;
|
break;
|
||||||
case 6:
|
case 6:
|
||||||
|
if(dwFlags & URL_DONT_SIMPLIFY) {
|
||||||
|
state = 3;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
/* Now at root location, cannot back up any more. */
|
/* Now at root location, cannot back up any more. */
|
||||||
/* "root" will point at the '/' */
|
/* "root" will point at the '/' */
|
||||||
|
|
||||||
root = wk2-1;
|
root = wk2-1;
|
||||||
while (*wk1) {
|
while (*wk1) {
|
||||||
TRACE("wk1=%c\n", (CHAR)*wk1);
|
|
||||||
|
|
||||||
mp = strchrW(wk1, '/');
|
mp = strchrW(wk1, '/');
|
||||||
mp2 = strchrW(wk1, '\\');
|
mp2 = strchrW(wk1, '\\');
|
||||||
if(mp2 && mp2 < mp)
|
if(mp2 && (!mp || mp2 < mp))
|
||||||
mp = mp2;
|
mp = mp2;
|
||||||
if (!mp) {
|
if (!mp) {
|
||||||
nWkLen = strlenW(wk1);
|
nWkLen = strlenW(wk1);
|
||||||
|
@ -474,7 +474,6 @@ HRESULT WINAPI UrlCanonicalizeW(LPCWSTR pszUrl, LPWSTR pszCanonicalized,
|
||||||
HeapFree(GetProcessHeap(), 0, lpszUrlCpy);
|
HeapFree(GetProcessHeap(), 0, lpszUrlCpy);
|
||||||
return E_INVALIDARG;
|
return E_INVALIDARG;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
*wk2 = L'\0';
|
*wk2 = L'\0';
|
||||||
TRACE("Simplified, orig <%s>, simple <%s>\n",
|
TRACE("Simplified, orig <%s>, simple <%s>\n",
|
||||||
debugstr_w(pszUrl), debugstr_w(lpszUrlCpy));
|
debugstr_w(pszUrl), debugstr_w(lpszUrlCpy));
|
||||||
|
|
Loading…
Reference in New Issue