Module: wine Branch: master Commit: 5024a05780d0adef2eb141212b2a66a55b658943 URL: http://source.winehq.org/git/wine.git/?a=commit;h=5024a05780d0adef2eb141212b...
Author: Piotr Caban piotr@codeweavers.com Date: Sun Nov 7 18:47:08 2010 +0100
shlwapi: Improved UrlCombineW implementation.
---
dlls/shlwapi/tests/url.c | 3 +++ dlls/shlwapi/url.c | 19 +++++++++++++++---- 2 files changed, 18 insertions(+), 4 deletions(-)
diff --git a/dlls/shlwapi/tests/url.c b/dlls/shlwapi/tests/url.c index 21e2f80..0a4dcb3 100644 --- a/dlls/shlwapi/tests/url.c +++ b/dlls/shlwapi/tests/url.c @@ -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%22%7D, {"http://www.winehq.org/tests/../tests/", "/tests10/..", URL_DONT_SIMPLIFY, S_OK, "http://www.winehq.org/tests10/..%22%7D, {"http://www.winehq.org/tests/../", "tests11", URL_DONT_SIMPLIFY, S_OK, "http://www.winehq.org/tests/../tests11%22%7D, + {"http://www.winehq.org/test12", "#", 0, S_OK, "http://www.winehq.org/test12#%22%7D, + {"http://www.winehq.org/test13#aaa", "#bbb", 0, S_OK, "http://www.winehq.org/test13#bbb%22%7D, + {"http://www.winehq.org/test14#aaa/bbb#ccc", "#", 0, S_OK, "http://www.winehq.org/test14#%22%7D, {"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"}, diff --git a/dlls/shlwapi/url.c b/dlls/shlwapi/url.c index adfbb09..ae2f408 100644 --- a/dlls/shlwapi/url.c +++ b/dlls/shlwapi/url.c @@ -730,7 +730,9 @@ HRESULT WINAPI UrlCombineW(LPCWSTR pszBase, LPCWSTR pszRelative, const WCHAR htmW[] = {'.','h','t','m',0}; 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; if (strncmpiW(work, htmW, len_htmW) == 0) manual_search = TRUE; @@ -750,15 +752,15 @@ HRESULT WINAPI UrlCombineW(LPCWSTR pszBase, LPCWSTR pszRelative, /* 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; + 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; - } + }else + base.cchSuffix = sizeloc; }
/* @@ -801,6 +803,15 @@ HRESULT WINAPI UrlCombineW(LPCWSTR pszBase, LPCWSTR pszRelative, process_case = 4; 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; break; }