shlwapi: Improved UrlCombineW implementation.

This commit is contained in:
Piotr Caban 2010-11-07 18:47:08 +01:00 committed by Alexandre Julliard
parent 872ba8af29
commit 5024a05780
2 changed files with 18 additions and 4 deletions

View File

@ -313,6 +313,9 @@ static 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"},
{"http://www.winehq.org/test12", "#", 0, S_OK, "http://www.winehq.org/test12#"},
{"http://www.winehq.org/test13#aaa", "#bbb", 0, S_OK, "http://www.winehq.org/test13#bbb"},
{"http://www.winehq.org/test14#aaa/bbb#ccc", "#", 0, S_OK, "http://www.winehq.org/test14#"},
{"file:///C:\\dir\\file.txt", "test.txt", 0, S_OK, "file:///C:/dir/test.txt"}, {"file:///C:\\dir\\file.txt", "test.txt", 0, S_OK, "file:///C:/dir/test.txt"},
{"file:///C:\\dir\\file.txt#hash\\hash", "test.txt", 0, S_OK, "file:///C:/dir/file.txt#hash/test.txt"}, {"file:///C:\\dir\\file.txt#hash\\hash", "test.txt", 0, S_OK, "file:///C:/dir/file.txt#hash/test.txt"},
{"file:///C:\\dir\\file.html#hash\\hash", "test.html", 0, S_OK, "file:///C:/dir/test.html"}, {"file:///C:\\dir\\file.html#hash\\hash", "test.html", 0, S_OK, "file:///C:/dir/test.html"},

View File

@ -730,7 +730,9 @@ HRESULT WINAPI UrlCombineW(LPCWSTR pszBase, LPCWSTR pszRelative,
const WCHAR htmW[] = {'.','h','t','m',0}; const WCHAR htmW[] = {'.','h','t','m',0};
const int len_htmW = 4; const int len_htmW = 4;
if (work - base.pszSuffix > len_htmW * sizeof(WCHAR)) { if (base.nScheme == URL_SCHEME_HTTP || base.nScheme == URL_SCHEME_HTTPS)
manual_search = TRUE;
else if (work - base.pszSuffix > len_htmW * sizeof(WCHAR)) {
work -= len_htmW; work -= len_htmW;
if (strncmpiW(work, htmW, len_htmW) == 0) if (strncmpiW(work, htmW, len_htmW) == 0)
manual_search = TRUE; manual_search = TRUE;
@ -750,15 +752,15 @@ HRESULT WINAPI UrlCombineW(LPCWSTR pszBase, LPCWSTR pszRelative,
/* search backwards starting from the current position */ /* search backwards starting from the current position */
while (*work != '/' && work > base.pszSuffix + sizeloc) while (*work != '/' && work > base.pszSuffix + sizeloc)
--work; --work;
if (work > base.pszSuffix + sizeloc) base.cchSuffix = work - base.pszSuffix + 1;
base.cchSuffix = work - base.pszSuffix + 1;
}else { }else {
/* search backwards starting from the end of the string */ /* search backwards starting from the end of the string */
work = strrchrW((base.pszSuffix+sizeloc), '/'); work = strrchrW((base.pszSuffix+sizeloc), '/');
if (work) { if (work) {
len = (DWORD)(work - base.pszSuffix + 1); len = (DWORD)(work - base.pszSuffix + 1);
base.cchSuffix = len; base.cchSuffix = len;
} }else
base.cchSuffix = sizeloc;
} }
/* /*
@ -801,6 +803,15 @@ HRESULT WINAPI UrlCombineW(LPCWSTR pszBase, LPCWSTR pszRelative,
process_case = 4; process_case = 4;
break; break;
} }
if (*mrelative == '#') {
if(!(work = strchrW(base.pszSuffix+base.cchSuffix, '#')))
work = (LPWSTR)base.pszSuffix + strlenW(base.pszSuffix);
memcpy(preliminary, base.pszProtocol, (work-base.pszProtocol)*sizeof(WCHAR));
preliminary[work-base.pszProtocol] = '\0';
process_case = 1;
break;
}
process_case = (*base.pszSuffix == '/' || base.nScheme == URL_SCHEME_MK) ? 5 : 3; process_case = (*base.pszSuffix == '/' || base.nScheme == URL_SCHEME_MK) ? 5 : 3;
break; break;
} }