[PATCH 2/3] msxml3: IXMLDOMDocument2's ::SetSite implementation should query site for base URI.

Dmitry Timoshkov dmitry at baikal.ru
Tue Jun 23 02:35:48 CDT 2020


Signed-off-by: Dmitry Timoshkov <dmitry at baikal.ru>
---
 dlls/msxml3/domdoc.c        | 11 +++++++++++
 dlls/msxml3/httprequest.c   | 16 ++++++++--------
 dlls/msxml3/msxml_private.h |  1 +
 dlls/msxml3/tests/domdoc.c  |  4 ----
 4 files changed, 20 insertions(+), 12 deletions(-)

diff --git a/dlls/msxml3/domdoc.c b/dlls/msxml3/domdoc.c
index 76d3fdb601..2a66fc9898 100644
--- a/dlls/msxml3/domdoc.c
+++ b/dlls/msxml3/domdoc.c
@@ -135,6 +135,7 @@ struct domdoc
 
     /* IObjectWithSite */
     IUnknown *site;
+    IUri *base_uri;
 
     /* IObjectSafety */
     DWORD safeopt;
@@ -963,6 +964,8 @@ static ULONG WINAPI domdoc_Release( IXMLDOMDocument3 *iface )
 
         if (This->site)
             IUnknown_Release( This->site );
+        if (This->base_uri)
+            IUri_Release( This->base_uri );
         destroy_xmlnode(&This->node);
 
         for (eid = 0; eid < EVENTID_LAST; eid++)
@@ -3551,6 +3554,12 @@ static HRESULT WINAPI domdoc_ObjectWithSite_SetSite( IObjectWithSite *iface, IUn
             This->site = NULL;
         }
 
+        if(This->base_uri)
+        {
+            IUri_Release(This->base_uri);
+            This->base_uri = NULL;
+        }
+
         return S_OK;
     }
 
@@ -3560,6 +3569,7 @@ static HRESULT WINAPI domdoc_ObjectWithSite_SetSite( IObjectWithSite *iface, IUn
         IUnknown_Release( This->site );
 
     This->site = punk;
+    This->base_uri = get_base_uri(This->site);
 
     return S_OK;
 }
@@ -3664,6 +3674,7 @@ HRESULT get_domdoc_from_xmldoc(xmlDocPtr xmldoc, IXMLDOMDocument3 **document)
     doc->properties = properties_from_xmlDocPtr(xmldoc);
     doc->error = S_OK;
     doc->site = NULL;
+    doc->base_uri = NULL;
     doc->safeopt = 0;
     doc->cp_list = NULL;
     doc->namespaces = NULL;
diff --git a/dlls/msxml3/httprequest.c b/dlls/msxml3/httprequest.c
index c6f9fdb33e..7286eb97bb 100644
--- a/dlls/msxml3/httprequest.c
+++ b/dlls/msxml3/httprequest.c
@@ -1598,7 +1598,7 @@ static HRESULT WINAPI httprequest_ObjectWithSite_GetSite( IObjectWithSite *iface
     return IUnknown_QueryInterface( This->site, iid, ppvSite );
 }
 
-static void get_base_uri(httprequest *This)
+IUri *get_base_uri(IUnknown *site)
 {
     IServiceProvider *provider;
     IHTMLDocument2 *doc;
@@ -1606,30 +1606,30 @@ static void get_base_uri(httprequest *This)
     BSTR url;
     HRESULT hr;
 
-    hr = IUnknown_QueryInterface(This->site, &IID_IServiceProvider, (void**)&provider);
+    hr = IUnknown_QueryInterface(site, &IID_IServiceProvider, (void**)&provider);
     if(FAILED(hr))
-        return;
+        return NULL;
 
     hr = IServiceProvider_QueryService(provider, &SID_SContainerDispatch, &IID_IHTMLDocument2, (void**)&doc);
     if(FAILED(hr))
         hr = IServiceProvider_QueryService(provider, &SID_SInternetHostSecurityManager, &IID_IHTMLDocument2, (void**)&doc);
     IServiceProvider_Release(provider);
     if(FAILED(hr))
-        return;
+        return NULL;
 
     hr = IHTMLDocument2_get_URL(doc, &url);
     IHTMLDocument2_Release(doc);
     if(FAILED(hr) || !url || !*url)
-        return;
+        return NULL;
 
     TRACE("host url %s\n", debugstr_w(url));
 
     hr = CreateUri(url, 0, 0, &uri);
     SysFreeString(url);
     if(FAILED(hr))
-        return;
+        return NULL;
 
-    This->base_uri = uri;
+    return uri;
 }
 
 static HRESULT WINAPI httprequest_ObjectWithSite_SetSite( IObjectWithSite *iface, IUnknown *punk )
@@ -1648,7 +1648,7 @@ static HRESULT WINAPI httprequest_ObjectWithSite_SetSite( IObjectWithSite *iface
     if (punk)
     {
         IUnknown_AddRef( punk );
-        get_base_uri(This);
+        This->base_uri = get_base_uri(This->site);
     }
 
     return S_OK;
diff --git a/dlls/msxml3/msxml_private.h b/dlls/msxml3/msxml_private.h
index 08f944ab1b..918c0d3d44 100644
--- a/dlls/msxml3/msxml_private.h
+++ b/dlls/msxml3/msxml_private.h
@@ -535,6 +535,7 @@ HRESULT create_moniker_from_url(LPCWSTR, IMoniker**) DECLSPEC_HIDDEN;
 HRESULT create_uri(const WCHAR *, IUri **) DECLSPEC_HIDDEN;
 HRESULT bind_url(IMoniker*, HRESULT (*onDataAvailable)(void*,char*,DWORD), void*, bsc_t**) DECLSPEC_HIDDEN;
 HRESULT detach_bsc(bsc_t*) DECLSPEC_HIDDEN;
+IUri *get_base_uri(IUnknown *) DECLSPEC_HIDDEN;
 
 /* Error Codes - not defined anywhere in the public headers */
 #define E_XML_ELEMENT_UNDECLARED            0xC00CE00D
diff --git a/dlls/msxml3/tests/domdoc.c b/dlls/msxml3/tests/domdoc.c
index b7cd57a069..27dfbda91b 100644
--- a/dlls/msxml3/tests/domdoc.c
+++ b/dlls/msxml3/tests/domdoc.c
@@ -13127,17 +13127,13 @@ static void test_load_with_site(void)
     qi_count = 0;
     hr = IObjectWithSite_SetSite(site, (IUnknown *)&sp);
     ok(hr == S_OK, "got %#x\n", hr);
-todo_wine
     ok(qi_count != 0, "got %d QI calls\n", qi_count);
 todo_wine
     ok(qi_list_contains(&IID_IXMLDOMDocument), "QI(IID_IXMLDOMDocument) was not called\n");
-todo_wine
     ok(qi_list_contains(&IID_IHTMLDocument2), "QI(IID_IHTMLDocument2) was not called\n");
-todo_wine
     ok(qi_list_contains(&IID_IServiceProvider), "QI(IID_IServiceProvider) was not called\n");
 todo_wine
     ok(qi_list_contains(&IID_IOleClientSite), "QI(IID_IOleClientSite) was not called\n");
-todo_wine
     ok(qi_list_contains_service(&SID_SContainerDispatch, &IID_IHTMLDocument2),
        "QI(SID_SContainerDispatch, IID_IHTMLDocument2) was not called\n");
 todo_wine
-- 
2.26.2




More information about the wine-devel mailing list