Nikolay Sivov : msxml3: Try mshtml container url as a base for relative request url.

Alexandre Julliard julliard at winehq.org
Wed Jan 11 13:39:59 CST 2012


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

Author: Nikolay Sivov <nsivov at codeweavers.com>
Date:   Wed Jan 11 05:19:48 2012 +0300

msxml3: Try mshtml container url as a base for relative request url.

---

 dlls/msxml3/httprequest.c  |   46 ++++++++++++++++++++++++++++++++++++++++++-
 dlls/msxml3/tests/domdoc.c |   16 +++++++++++++-
 dlls/uuid/uuid.c           |    5 +++-
 include/docobj.idl         |    2 +
 4 files changed, 64 insertions(+), 5 deletions(-)

diff --git a/dlls/msxml3/httprequest.c b/dlls/msxml3/httprequest.c
index 79bf34d..ff4ab21 100644
--- a/dlls/msxml3/httprequest.c
+++ b/dlls/msxml3/httprequest.c
@@ -33,10 +33,16 @@
 
 #include "windef.h"
 #include "winbase.h"
+#include "wingdi.h"
+#include "wininet.h"
+#include "winreg.h"
 #include "winuser.h"
 #include "ole2.h"
+#include "mshtml.h"
 #include "msxml6.h"
 #include "objsafe.h"
+#include "docobj.h"
+#include "shlwapi.h"
 
 #include "msxml_private.h"
 
@@ -72,6 +78,7 @@ typedef struct
     /* request */
     BINDVERB verb;
     BSTR custom;
+    BSTR siteurl;
     BSTR url;
     BOOL async;
     struct list reqheaders;
@@ -767,6 +774,7 @@ static ULONG WINAPI httprequest_Release(IXMLHTTPRequest *iface)
             IUnknown_Release( This->site );
 
         SysFreeString(This->custom);
+        SysFreeString(This->siteurl);
         SysFreeString(This->url);
         SysFreeString(This->user);
         SysFreeString(This->password);
@@ -906,7 +914,22 @@ static HRESULT WINAPI httprequest_open(IXMLHTTPRequest *iface, BSTR method, BSTR
         return E_FAIL;
     }
 
-    This->url = SysAllocString(url);
+    /* try to combine with site url */
+    if (This->siteurl && PathIsRelativeW(url))
+    {
+        DWORD len = INTERNET_MAX_URL_LENGTH;
+        WCHAR *fullW = heap_alloc(len*sizeof(WCHAR));
+
+        hr = UrlCombineW(This->siteurl, url, fullW, &len, 0);
+        if (hr == S_OK)
+        {
+            TRACE("combined url %s\n", debugstr_w(fullW));
+            This->url = SysAllocString(fullW);
+        }
+        heap_free(fullW);
+    }
+    else
+        This->url = SysAllocString(url);
 
     VariantInit(&is_async);
     hr = VariantChangeType(&is_async, &async, 0, VT_BOOL);
@@ -1324,6 +1347,8 @@ static HRESULT WINAPI httprequest_ObjectWithSite_GetSite( IObjectWithSite *iface
 static HRESULT WINAPI httprequest_ObjectWithSite_SetSite( IObjectWithSite *iface, IUnknown *punk )
 {
     httprequest *This = impl_from_IObjectWithSite(iface);
+    IServiceProvider *provider;
+    HRESULT hr;
 
     TRACE("(%p)->(%p)\n", iface, punk);
 
@@ -1335,6 +1360,23 @@ static HRESULT WINAPI httprequest_ObjectWithSite_SetSite( IObjectWithSite *iface
 
     This->site = punk;
 
+    hr = IUnknown_QueryInterface(This->site, &IID_IServiceProvider, (void**)&provider);
+    if (hr == S_OK)
+    {
+        IHTMLDocument2 *doc;
+
+        hr = IServiceProvider_QueryService(provider, &SID_SContainerDispatch, &IID_IHTMLDocument2, (void**)&doc);
+        if (hr == S_OK)
+        {
+            SysFreeString(This->siteurl);
+
+            hr = IHTMLDocument2_get_URL(doc, &This->siteurl);
+            IHTMLDocument2_Release(doc);
+            TRACE("host url %s, 0x%08x\n", debugstr_w(This->siteurl), hr);
+        }
+        IServiceProvider_Release(provider);
+    }
+
     return S_OK;
 }
 
@@ -1426,7 +1468,7 @@ HRESULT XMLHTTPRequest_create(IUnknown *pUnkOuter, void **ppObj)
     req->async = FALSE;
     req->verb = -1;
     req->custom = NULL;
-    req->url = req->user = req->password = NULL;
+    req->url = req->siteurl = req->user = req->password = NULL;
 
     req->state = READYSTATE_UNINITIALIZED;
     req->sink = NULL;
diff --git a/dlls/msxml3/tests/domdoc.c b/dlls/msxml3/tests/domdoc.c
index 5ed8715..a4e5ab1 100644
--- a/dlls/msxml3/tests/domdoc.c
+++ b/dlls/msxml3/tests/domdoc.c
@@ -5000,11 +5000,11 @@ todo_wine {
     hr = IObjectWithSite_SetSite(obj_site, &testsite.IUnknown_iface);
     EXPECT_HR(hr, S_OK);
 
-todo_wine{
     CHECK_CALLED(site_qi_IServiceProvider);
-
+todo_wine
     CHECK_CALLED(sp_queryservice_SID_SBindHost);
     CHECK_CALLED(sp_queryservice_SID_SContainerDispatch_htmldoc2);
+todo_wine {
     CHECK_CALLED(sp_queryservice_SID_secmgr_htmldoc2);
     CHECK_CALLED(sp_queryservice_SID_secmgr_xmldomdoc);
     /* this one isn't very reliable
@@ -5019,11 +5019,23 @@ todo_wine{
 }
     IObjectWithSite_Release(obj_site);
 
+    /* try to set site another time */
+
+    /* to be removed once IObjectWithSite is properly separated */
+    SET_EXPECT(site_qi_IServiceProvider);
+    SET_EXPECT(sp_queryservice_SID_SContainerDispatch_htmldoc2);
+
+    hr = IObjectWithSite_SetSite(obj_site2, &testsite.IUnknown_iface);
+    EXPECT_HR(hr, S_OK);
+
     todo_wine EXPECT_REF(xhr, 1);
     IXMLHttpRequest_Release(xhr);
 
     /* still works after request is released */
+
+    /* to be removed once IObjectWithSite is properly separated */
     SET_EXPECT(site_qi_IServiceProvider);
+    SET_EXPECT(sp_queryservice_SID_SContainerDispatch_htmldoc2);
 
     hr = IObjectWithSite_SetSite(obj_site2, &testsite.IUnknown_iface);
     EXPECT_HR(hr, S_OK);
diff --git a/dlls/uuid/uuid.c b/dlls/uuid/uuid.c
index 3318dd6..25e98a7 100644
--- a/dlls/uuid/uuid.c
+++ b/dlls/uuid/uuid.c
@@ -126,7 +126,7 @@ DEFINE_GUID(CLSID_TF_DisplayAttributeMgr, 0x3ce74de4,0x53d3,0x4d74,0x8b,0x83,0x4
 DEFINE_GUID(GUID_TFCAT_TIP_KEYBOARD,     0x34745c63,0xb2f0,0x4784,0x8b,0x67,0x5e,0x12,0xc8,0x70,0x1a,0x31);
 DEFINE_GUID(GUID_TFCAT_TIP_SPEECH,       0xB5A73CD1,0x8355,0x426B,0xA1,0x61,0x25,0x98,0x08,0xF2,0x6B,0x14);
 DEFINE_GUID(GUID_TFCAT_TIP_HANDWRITING,  0x246ecb87,0xc2f2,0x4abe,0x90,0x5b,0xc8,0xb3,0x8a,0xdd,0x2c,0x43);
-DEFINE_GUID (GUID_TFCAT_DISPLAYATTRIBUTEPROVIDER,  0x046B8C80,0x1647,0x40F7,0x9B,0x21,0xB9,0x3B,0x81,0xAA,0xBC,0x1B);
+DEFINE_GUID(GUID_TFCAT_DISPLAYATTRIBUTEPROVIDER,  0x046B8C80,0x1647,0x40F7,0x9B,0x21,0xB9,0x3B,0x81,0xAA,0xBC,0x1B);
 DEFINE_GUID(GUID_COMPARTMENT_KEYBOARD_DISABLED,     0x71a5b253,0x1951,0x466b,0x9f,0xbc,0x9c,0x88,0x08,0xfa,0x84,0xf2);
 DEFINE_GUID(GUID_COMPARTMENT_KEYBOARD_OPENCLOSE,    0x58273aad,0x01bb,0x4164,0x95,0xc6,0x75,0x5b,0xa0,0xb5,0x16,0x2d);
 DEFINE_GUID(GUID_COMPARTMENT_HANDWRITING_OPENCLOSE, 0xf9ae2c6b,0x1866,0x4361,0xaf,0x72,0x7a,0xa3,0x09,0x48,0x89,0x0e);
@@ -136,3 +136,6 @@ DEFINE_GUID(GUID_COMPARTMENT_SPEECH_GLOBALSTATE,    0x2a54fe8e,0x0d08,0x460c,0xa
 DEFINE_GUID(GUID_COMPARTMENT_PERSISTMENUENABLED,    0x575f3783,0x70c8,0x47c8,0xae,0x5d,0x91,0xa0,0x1a,0x1f,0x75,0x92);
 DEFINE_GUID(GUID_COMPARTMENT_EMPTYCONTEXT,          0xd7487dbf,0x804e,0x41c5,0x89,0x4d,0xad,0x96,0xfd,0x4e,0xea,0x13);
 DEFINE_GUID(GUID_COMPARTMENT_TIPUISTATUS,           0x148ca3ec,0x0366,0x401c,0x8d,0x75,0xed,0x97,0x8d,0x85,0xfb,0xc9);
+
+/* service identifiers not declared in headers */
+DEFINE_GUID(SID_SContainerDispatch,0xb722be00,0x4e68,0x101b,0xa2,0xbc,0x00,0xaa,0x00,0x40,0x47,0x70);
diff --git a/include/docobj.idl b/include/docobj.idl
index bc14b1d..c77e546 100644
--- a/include/docobj.idl
+++ b/include/docobj.idl
@@ -407,3 +407,5 @@ cpp_quote("#define IID_IMsoDocumentSite           IID_IOleDocumentSite")
 cpp_quote("#define IID_IMsoView                   IID_IOleDocumentView")
 cpp_quote("#define IID_IEnumMsoView               IID_IEnumOleDocumentViews")
 cpp_quote("#define IID_IMsoCommandTarget          IID_IOleCommandTarget")
+
+cpp_quote("EXTERN_C const GUID SID_SContainerDispatch;")




More information about the wine-cvs mailing list