shlwapi: Ignore the hash of HTML URLs in UrlCombine.

This commit is contained in:
Andrew Eikum 2010-02-26 19:20:42 -06:00 committed by Alexandre Julliard
parent ef4a9cadf5
commit 386cb659df
2 changed files with 46 additions and 7 deletions

View File

@ -278,6 +278,11 @@ static const TEST_URL_COMBINE TEST_COMBINE[] = {
{"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"},
{"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.html#hash\\hash", "test.html", 0, S_OK, "file:///C:/dir/test.html"},
{"file:///C:\\dir\\file.htm#hash\\hash", "test.htm", 0, S_OK, "file:///C:/dir/test.htm"},
{"file:///C:\\dir\\file.hTmL#hash\\hash", "test.hTmL", 0, S_OK, "file:///C:/dir/test.hTmL"},
{"file:///C:\\dir.html\\file.txt#hash\\hash", "test.txt", 0, S_OK, "file:///C:/dir.html/file.txt#hash/test.txt"},
{"C:\\winehq\\winehq.txt", "C:\\Test\\test.txt", 0, S_OK, "file:///C:/Test/test.txt"},
{"http://www.winehq.org/test/", "test%20file.txt", 0, S_OK, "http://www.winehq.org/test/test%20file.txt"},
{"http://www.winehq.org/test/", "test%20file.txt", URL_FILE_USE_PATHURL, S_OK, "http://www.winehq.org/test/test%20file.txt"},

View File

@ -630,6 +630,8 @@ HRESULT WINAPI UrlCombineW(LPCWSTR pszBase, LPCWSTR pszRelative,
process_case = 1;
}
else do {
BOOL manual_search = FALSE;
/* mk is a special case */
if(base.nScheme == URL_SCHEME_MK) {
static const WCHAR wsz[] = {':',':',0};
@ -659,13 +661,45 @@ HRESULT WINAPI UrlCombineW(LPCWSTR pszBase, LPCWSTR pszRelative,
}
}
/* Change .sizep2 to not have the last leaf in it,
* Note: we need to start after the location (if it exists)
*/
work = strrchrW((base.pszSuffix+sizeloc), '/');
if (work) {
len = (DWORD)(work - base.pszSuffix + 1);
base.cchSuffix = len;
/* If there is a '#' and the characters immediately preceeding it are
* ".htm[l]", then begin looking for the last leaf starting from
* the '#'. Otherwise the '#' is not meaningful and just start
* looking from the end. */
if ((work = strchrW(base.pszSuffix + sizeloc, '#'))) {
const WCHAR htmlW[] = {'.','h','t','m','l',0};
const int len_htmlW = 5;
const WCHAR htmW[] = {'.','h','t','m',0};
const int len_htmW = 4;
if (work - base.pszSuffix > len_htmW * sizeof(WCHAR)) {
work -= len_htmW;
if (strncmpiW(work, htmW, len_htmW) == 0)
manual_search = TRUE;
work += len_htmW;
}
if (!manual_search &&
work - base.pszSuffix > len_htmlW * sizeof(WCHAR)) {
work -= len_htmlW;
if (strncmpiW(work, htmlW, len_htmlW) == 0)
manual_search = TRUE;
work += len_htmlW;
}
}
if (manual_search) {
/* search backwards starting from the current position */
while (*work != '/' && work > base.pszSuffix + sizeloc)
--work;
if (work > base.pszSuffix + sizeloc)
base.cchSuffix = work - base.pszSuffix + 1;
}else {
/* search backwards starting from the end of the string */
work = strrchrW((base.pszSuffix+sizeloc), '/');
if (work) {
len = (DWORD)(work - base.pszSuffix + 1);
base.cchSuffix = len;
}
}
/*