msxml3: Set referrer header to container url.

This commit is contained in:
Nikolay Sivov 2013-10-17 12:12:31 +04:00 committed by Alexandre Julliard
parent 3988ee9465
commit 13aac41b06
2 changed files with 74 additions and 7 deletions

View File

@ -458,9 +458,11 @@ static HRESULT WINAPI BSCHttpNegotiate_BeginningTransaction(IHttpNegotiate *ifac
{ {
static const WCHAR content_type_utf8W[] = {'C','o','n','t','e','n','t','-','T','y','p','e',':',' ', static const WCHAR content_type_utf8W[] = {'C','o','n','t','e','n','t','-','T','y','p','e',':',' ',
't','e','x','t','/','p','l','a','i','n',';','c','h','a','r','s','e','t','=','u','t','f','-','8','\r','\n',0}; 't','e','x','t','/','p','l','a','i','n',';','c','h','a','r','s','e','t','=','u','t','f','-','8','\r','\n',0};
static const WCHAR refererW[] = {'R','e','f','e','r','e','r',':',' ',0};
BindStatusCallback *This = impl_from_IHttpNegotiate(iface); BindStatusCallback *This = impl_from_IHttpNegotiate(iface);
const struct httpheader *entry; const struct httpheader *entry;
BSTR base_uri = NULL;
WCHAR *buff, *ptr; WCHAR *buff, *ptr;
int size = 0; int size = 0;
@ -476,8 +478,18 @@ static HRESULT WINAPI BSCHttpNegotiate_BeginningTransaction(IHttpNegotiate *ifac
if (!size) return S_OK; if (!size) return S_OK;
if (This->request->base_uri)
{
IUri_GetRawUri(This->request->base_uri, &base_uri);
size += SysStringLen(base_uri)*sizeof(WCHAR) + sizeof(refererW) + sizeof(crlfW);
}
buff = CoTaskMemAlloc(size); buff = CoTaskMemAlloc(size);
if (!buff) return E_OUTOFMEMORY; if (!buff)
{
SysFreeString(base_uri);
return E_OUTOFMEMORY;
}
ptr = buff; ptr = buff;
if (This->request->use_utf8_content) if (This->request->use_utf8_content)
@ -486,6 +498,15 @@ static HRESULT WINAPI BSCHttpNegotiate_BeginningTransaction(IHttpNegotiate *ifac
ptr += sizeof(content_type_utf8W)/sizeof(WCHAR)-1; ptr += sizeof(content_type_utf8W)/sizeof(WCHAR)-1;
} }
if (base_uri)
{
strcpyW(ptr, refererW);
strcatW(ptr, base_uri);
strcatW(ptr, crlfW);
ptr += strlenW(refererW) + SysStringLen(base_uri) + strlenW(crlfW);
SysFreeString(base_uri);
}
/* user headers */ /* user headers */
LIST_FOR_EACH_ENTRY(entry, &This->request->reqheaders, struct httpheader, entry) LIST_FOR_EACH_ENTRY(entry, &This->request->reqheaders, struct httpheader, entry)
{ {
@ -1571,6 +1592,8 @@ static void get_base_uri(httprequest *This)
return; return;
hr = IServiceProvider_QueryService(provider, &SID_SContainerDispatch, &IID_IHTMLDocument2, (void**)&doc); 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); IServiceProvider_Release(provider);
if(FAILED(hr)) if(FAILED(hr))
return; return;

View File

@ -51,6 +51,8 @@ static void _expect_ref(IUnknown* obj, ULONG ref, int line)
DEFINE_GUID(SID_SContainerDispatch, 0xb722be00, 0x4e68, 0x101b, 0xa2, 0xbc, 0x00, 0xaa, 0x00, 0x40, 0x47, 0x70); DEFINE_GUID(SID_SContainerDispatch, 0xb722be00, 0x4e68, 0x101b, 0xa2, 0xbc, 0x00, 0xaa, 0x00, 0x40, 0x47, 0x70);
DEFINE_GUID(SID_UnknownSID, 0x75dd09cb, 0x6c40, 0x11d5, 0x85, 0x43, 0x00, 0xc0, 0x4f, 0xa0, 0xfb, 0xa3); DEFINE_GUID(SID_UnknownSID, 0x75dd09cb, 0x6c40, 0x11d5, 0x85, 0x43, 0x00, 0xc0, 0x4f, 0xa0, 0xfb, 0xa3);
static BOOL g_enablecallchecks;
#define DEFINE_EXPECT(func) \ #define DEFINE_EXPECT(func) \
static BOOL expect_ ## func = FALSE, called_ ## func = FALSE static BOOL expect_ ## func = FALSE, called_ ## func = FALSE
@ -59,6 +61,7 @@ DEFINE_GUID(SID_UnknownSID, 0x75dd09cb, 0x6c40, 0x11d5, 0x85, 0x43, 0x00, 0xc0,
#define CHECK_EXPECT2(func) \ #define CHECK_EXPECT2(func) \
do { \ do { \
if (g_enablecallchecks) \
ok(expect_ ##func, "unexpected call " #func "\n"); \ ok(expect_ ##func, "unexpected call " #func "\n"); \
called_ ## func = TRUE; \ called_ ## func = TRUE; \
}while(0) }while(0)
@ -1147,6 +1150,18 @@ static HRESULT WINAPI sp_QueryService(IServiceProvider *iface, REFGUID service,
{ {
/* FIXME: unidentified service id */ /* FIXME: unidentified service id */
} }
else if (IsEqualGUID(service, &IID_IInternetProtocol) &&
IsEqualGUID(riid, &IID_IInternetProtocol))
{
}
else if (IsEqualGUID(service, &IID_IHttpNegotiate2) &&
IsEqualGUID(riid, &IID_IHttpNegotiate2))
{
}
else if (IsEqualGUID(service, &IID_IGetBindHandle) &&
IsEqualGUID(riid, &IID_IGetBindHandle))
{
}
else else
ok(0, "unexpected request: sid %s, riid %s\n", debugstr_guid(service), debugstr_guid(riid)); ok(0, "unexpected request: sid %s, riid %s\n", debugstr_guid(service), debugstr_guid(riid));
@ -1365,6 +1380,8 @@ static void set_xhr_site(IXMLHttpRequest *xhr)
hr = IXMLHttpRequest_QueryInterface(xhr, &IID_IObjectWithSite, (void**)&obj_site); hr = IXMLHttpRequest_QueryInterface(xhr, &IID_IObjectWithSite, (void**)&obj_site);
ok(hr == S_OK, "Could not get IObjectWithSite iface: %08x\n", hr); ok(hr == S_OK, "Could not get IObjectWithSite iface: %08x\n", hr);
g_enablecallchecks = TRUE;
SET_EXPECT(site_qi_IServiceProvider); SET_EXPECT(site_qi_IServiceProvider);
SET_EXPECT(sp_queryservice_SID_SBindHost); SET_EXPECT(sp_queryservice_SID_SBindHost);
SET_EXPECT(sp_queryservice_SID_SContainerDispatch_htmldoc2); SET_EXPECT(sp_queryservice_SID_SContainerDispatch_htmldoc2);
@ -1387,20 +1404,24 @@ static void set_xhr_site(IXMLHttpRequest *xhr)
todo_wine todo_wine
CHECK_CALLED(sp_queryservice_SID_SBindHost); CHECK_CALLED(sp_queryservice_SID_SBindHost);
CHECK_CALLED(sp_queryservice_SID_SContainerDispatch_htmldoc2); CHECK_CALLED(sp_queryservice_SID_SContainerDispatch_htmldoc2);
todo_wine {
CHECK_CALLED(sp_queryservice_SID_secmgr_htmldoc2); CHECK_CALLED(sp_queryservice_SID_secmgr_htmldoc2);
todo_wine
CHECK_CALLED(sp_queryservice_SID_secmgr_xmldomdoc); CHECK_CALLED(sp_queryservice_SID_secmgr_xmldomdoc);
/* this one isn't very reliable /* this one isn't very reliable
CHECK_CALLED(sp_queryservice_SID_secmgr_secmgr); */ CHECK_CALLED(sp_queryservice_SID_secmgr_secmgr); */
todo_wine {
CHECK_CALLED(htmldoc2_get_all); CHECK_CALLED(htmldoc2_get_all);
CHECK_CALLED(collection_get_length); CHECK_CALLED(collection_get_length);
}
CHECK_CALLED(htmldoc2_get_url); CHECK_CALLED(htmldoc2_get_url);
todo_wine {
CHECK_CALLED(site_qi_IXMLDOMDocument); CHECK_CALLED(site_qi_IXMLDOMDocument);
CHECK_CALLED(site_qi_IOleClientSite); CHECK_CALLED(site_qi_IOleClientSite);
} }
g_enablecallchecks = FALSE;
IObjectWithSite_Release(obj_site); IObjectWithSite_Release(obj_site);
} }
@ -1423,8 +1444,10 @@ static void test_XMLHTTP(void)
static const char bodyA[] = "mode=Test"; static const char bodyA[] = "mode=Test";
static const char urlA[] = "http://crossover.codeweavers.com/posttest.php"; static const char urlA[] = "http://crossover.codeweavers.com/posttest.php";
static const char xmltestA[] = "http://crossover.codeweavers.com/xmltest.xml"; static const char xmltestA[] = "http://crossover.codeweavers.com/xmltest.xml";
static const char referertesturl[] = "http://test.winehq.org/tests/referer.php";
static const WCHAR wszExpectedResponse[] = {'F','A','I','L','E','D',0}; static const WCHAR wszExpectedResponse[] = {'F','A','I','L','E','D',0};
static const CHAR xmltestbodyA[] = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<a>TEST</a>\n"; static const CHAR xmltestbodyA[] = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<a>TEST</a>\n";
static const WCHAR norefererW[] = {'n','o',' ','r','e','f','e','r','e','r',' ','s','e','t',0};
IXMLHttpRequest *xhr; IXMLHttpRequest *xhr;
IObjectWithSite *obj_site, *obj_site2; IObjectWithSite *obj_site, *obj_site2;
@ -1686,6 +1709,17 @@ static void test_XMLHTTP(void)
IDispatch_Release(event); IDispatch_Release(event);
/* test if referrer header is sent */
test_open(xhr, "GET", referertesturl, S_OK);
V_VT(&varbody) = VT_EMPTY;
hr = IXMLHttpRequest_send(xhr, varbody);
ok(hr == S_OK, "got 0x%08x\n", hr);
hr = IXMLHttpRequest_get_responseText(xhr, &str);
ok(hr == S_OK, "got 0x%08x\n", hr);
ok(!lstrcmpW(str, norefererW), "got response text %s\n", wine_dbgstr_w(str));
SysFreeString(str);
/* interaction with object site */ /* interaction with object site */
hr = IXMLHttpRequest_QueryInterface(xhr, &IID_IObjectWithSite, (void**)&obj_site); hr = IXMLHttpRequest_QueryInterface(xhr, &IID_IObjectWithSite, (void**)&obj_site);
EXPECT_HR(hr, S_OK); EXPECT_HR(hr, S_OK);
@ -1700,10 +1734,20 @@ static void test_XMLHTTP(void)
set_xhr_site(xhr); set_xhr_site(xhr);
/* try to set site another time */ test_open(xhr, "GET", "tests/referer.php", S_OK);
SET_EXPECT(site_qi_IServiceProvider); str1 = a2bstr("http://test.winehq.org/");
SET_EXPECT(sp_queryservice_SID_SContainerDispatch_htmldoc2);
V_VT(&varbody) = VT_EMPTY;
hr = IXMLHttpRequest_send(xhr, varbody);
ok(hr == S_OK, "got 0x%08x\n", hr);
hr = IXMLHttpRequest_get_responseText(xhr, &str);
ok(hr == S_OK, "got 0x%08x\n", hr);
ok(!lstrcmpW(str, str1), "got response text %s, expected %s\n", wine_dbgstr_w(str), wine_dbgstr_w(str1));
SysFreeString(str);
SysFreeString(str1);
/* try to set site another time */
hr = IObjectWithSite_SetSite(obj_site, &testsite); hr = IObjectWithSite_SetSite(obj_site, &testsite);
EXPECT_HR(hr, S_OK); EXPECT_HR(hr, S_OK);