Piotr Caban : shlwapi: Improved UrlCombineW implementation.

Alexandre Julliard julliard at winehq.org
Mon Nov 8 11:46:21 CST 2010


Module: wine
Branch: master
Commit: 5024a05780d0adef2eb141212b2a66a55b658943
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=5024a05780d0adef2eb141212b2a66a55b658943

Author: Piotr Caban <piotr at 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"},
     {"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/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#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;
 	}




More information about the wine-cvs mailing list