Andrew Eikum : shlwapi: Ignore the hash of HTML URLs in UrlCombine.
Alexandre Julliard
julliard at winehq.org
Mon Mar 1 09:27:38 CST 2010
Module: wine
Branch: master
Commit: 386cb659df0f7e7616d62332f6a116b8a0c74a8b
URL: http://source.winehq.org/git/wine.git/?a=commit;h=386cb659df0f7e7616d62332f6a116b8a0c74a8b
Author: Andrew Eikum <aeikum at codeweavers.com>
Date: Fri Feb 26 19:20:42 2010 -0600
shlwapi: Ignore the hash of HTML URLs in UrlCombine.
---
dlls/shlwapi/tests/url.c | 5 ++++
dlls/shlwapi/url.c | 48 +++++++++++++++++++++++++++++++++++++++------
2 files changed, 46 insertions(+), 7 deletions(-)
diff --git a/dlls/shlwapi/tests/url.c b/dlls/shlwapi/tests/url.c
index 3d86ae7..31df64e 100644
--- a/dlls/shlwapi/tests/url.c
+++ b/dlls/shlwapi/tests/url.c
@@ -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"},
diff --git a/dlls/shlwapi/url.c b/dlls/shlwapi/url.c
index 4a93b23..2fdae3d 100644
--- a/dlls/shlwapi/url.c
+++ b/dlls/shlwapi/url.c
@@ -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;
+ }
}
/*
More information about the wine-cvs
mailing list