Jacek Caban : urlmon: Use CoInternetParseUrl in URLMonikerImpl_Construct.

Alexandre Julliard julliard at wine.codeweavers.com
Mon Jul 31 04:32:06 CDT 2006


Module: wine
Branch: refs/heads/master
Commit: 5674260b6dd64c1dc6e58697a682757e3902a66e
URL:    http://source.winehq.org/git/?p=wine.git;a=commit;h=5674260b6dd64c1dc6e58697a682757e3902a66e

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Sat Jul 29 14:53:22 2006 +0200

urlmon: Use CoInternetParseUrl in URLMonikerImpl_Construct.

---

 dlls/urlmon/umon.c |   39 +++++++++++++++------------------------
 1 files changed, 15 insertions(+), 24 deletions(-)

diff --git a/dlls/urlmon/umon.c b/dlls/urlmon/umon.c
index c81b3a3..715db8d 100644
--- a/dlls/urlmon/umon.c
+++ b/dlls/urlmon/umon.c
@@ -1060,43 +1060,34 @@ static const IMonikerVtbl VT_URLMonikerI
 static HRESULT URLMonikerImpl_Construct(URLMonikerImpl* This, LPCOLESTR lpszLeftURLName, LPCOLESTR lpszURLName)
 {
     HRESULT hres;
-    DWORD sizeStr = INTERNET_MAX_URL_LENGTH;
+    DWORD sizeStr = 0;
 
     TRACE("(%p,%s,%s)\n",This,debugstr_w(lpszLeftURLName),debugstr_w(lpszURLName));
 
     This->lpvtbl = &VT_URLMonikerImpl;
     This->ref = 0;
 
-    sizeStr = lstrlenW(lpszURLName)+1;
-    if(lpszLeftURLName)
-        sizeStr += strlenW(lpszLeftURLName)+32;
-
-    This->URLName = HeapAlloc(GetProcessHeap(), 0, sizeStr*sizeof(WCHAR));
+    This->URLName = HeapAlloc(GetProcessHeap(), 0, INTERNET_MAX_URL_LENGTH*sizeof(WCHAR));
 
-    if(lpszLeftURLName) {
+    if(lpszLeftURLName)
         hres = CoInternetCombineUrl(lpszLeftURLName, lpszURLName, URL_FILE_USE_PATHURL,
-                                    This->URLName, sizeStr, &sizeStr, 0);
-        if(FAILED(hres)) {
-            HeapFree(GetProcessHeap(), 0, This->URLName);
-            return hres;
-        }
-    }else {
-        /* FIXME:
-         * We probably should use CoInternetParseUrl or something similar here.
-         */
-
-        static const WCHAR wszFile[] = {'f','i','l','e',':','/','/',};
+                This->URLName, INTERNET_MAX_URL_LENGTH, &sizeStr, 0);
+    else
+        hres = CoInternetParseUrl(lpszURLName, PARSE_CANONICALIZE, URL_FILE_USE_PATHURL,
+                This->URLName, INTERNET_MAX_URL_LENGTH, &sizeStr, 0);
 
-        /* file protocol is a special case */
-        if(sizeStr > sizeof(wszFile)/sizeof(WCHAR)
-                && !memcmp(lpszURLName, wszFile, sizeof(wszFile)))
-            UrlCanonicalizeW(lpszURLName, This->URLName, &sizeStr, URL_FILE_USE_PATHURL);
-        else
-            strcpyW(This->URLName,lpszURLName);
+    if(FAILED(hres)) {
+        HeapFree(GetProcessHeap(), 0, This->URLName);
+        return hres;
     }
 
     URLMON_LockModule();
 
+    if(sizeStr != INTERNET_MAX_URL_LENGTH)
+        This->URLName = HeapReAlloc(GetProcessHeap(), 0, This->URLName, (sizeStr+1)*sizeof(WCHAR));
+
+    TRACE("URLName = %s\n", debugstr_w(This->URLName));
+
     return S_OK;
 }
 




More information about the wine-cvs mailing list