msxml3: Handle passed BSTR argument as a WCHAR string in ::createProcessingInstruction().
This commit is contained in:
parent
052eb24b03
commit
adfd305821
|
@ -1597,15 +1597,11 @@ static HRESULT WINAPI domdoc_createProcessingInstruction(
|
|||
hr = IXMLDOMDocument3_createNode(iface, type, target, NULL, &node);
|
||||
if (hr == S_OK)
|
||||
{
|
||||
VARIANT v_data;
|
||||
xmlnode *node_obj;
|
||||
|
||||
/* this is to bypass check in ::put_data() that blocks "<?xml" PIs */
|
||||
node_obj = get_node_obj(node);
|
||||
V_VT(&v_data) = VT_BSTR;
|
||||
V_BSTR(&v_data) = data;
|
||||
|
||||
hr = node_put_value(node_obj, &v_data);
|
||||
hr = node_set_content(node_obj, data);
|
||||
|
||||
IXMLDOMNode_QueryInterface(node, &IID_IXMLDOMProcessingInstruction, (void**)pi);
|
||||
IXMLDOMNode_Release(node);
|
||||
|
|
|
@ -162,6 +162,7 @@ extern xmlnode *get_node_obj(IXMLDOMNode*);
|
|||
|
||||
extern HRESULT node_get_nodeName(xmlnode*,BSTR*);
|
||||
extern HRESULT node_get_content(xmlnode*,VARIANT*);
|
||||
extern HRESULT node_set_content(xmlnode*,LPCWSTR);
|
||||
extern HRESULT node_put_value(xmlnode*,VARIANT*);
|
||||
extern HRESULT node_get_parent(xmlnode*,IXMLDOMNode**);
|
||||
extern HRESULT node_get_child_nodes(xmlnode*,IXMLDOMNodeList**);
|
||||
|
|
|
@ -138,10 +138,22 @@ HRESULT node_get_content(xmlnode *This, VARIANT *value)
|
|||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT node_set_content(xmlnode *This, LPCWSTR value)
|
||||
{
|
||||
xmlChar *str;
|
||||
|
||||
str = xmlChar_from_wchar(value);
|
||||
if(!str)
|
||||
return E_OUTOFMEMORY;
|
||||
|
||||
xmlNodeSetContent(This->node, str);
|
||||
heap_free(str);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT node_put_value(xmlnode *This, VARIANT *value)
|
||||
{
|
||||
VARIANT string_value;
|
||||
xmlChar *str;
|
||||
HRESULT hr;
|
||||
|
||||
VariantInit(&string_value);
|
||||
|
@ -151,11 +163,9 @@ HRESULT node_put_value(xmlnode *This, VARIANT *value)
|
|||
return hr;
|
||||
}
|
||||
|
||||
str = xmlChar_from_wchar(V_BSTR(&string_value));
|
||||
hr = node_set_content(This, V_BSTR(&string_value));
|
||||
VariantClear(&string_value);
|
||||
|
||||
xmlNodeSetContent(This->node, str);
|
||||
heap_free(str);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -7125,6 +7125,28 @@ static void test_events(void)
|
|||
IXMLDOMDocument_Release(doc);
|
||||
}
|
||||
|
||||
static void test_createProcessingInstruction(void)
|
||||
{
|
||||
static const WCHAR bodyW[] = {'t','e','s','t',0};
|
||||
IXMLDOMProcessingInstruction *pi;
|
||||
IXMLDOMDocument *doc;
|
||||
WCHAR buff[10];
|
||||
HRESULT hr;
|
||||
|
||||
doc = create_document(&IID_IXMLDOMDocument);
|
||||
if (!doc) return;
|
||||
|
||||
/* test for BSTR handling, pass broken BSTR */
|
||||
memcpy(&buff[2], bodyW, sizeof(bodyW));
|
||||
/* just a big length */
|
||||
*(DWORD*)buff = 0xf0f0;
|
||||
hr = IXMLDOMDocument_createProcessingInstruction(doc, _bstr_("test"), &buff[2], &pi);
|
||||
ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||
|
||||
IXMLDOMProcessingInstruction_Release(pi);
|
||||
IXMLDOMDocument_Release(doc);
|
||||
}
|
||||
|
||||
START_TEST(domdoc)
|
||||
{
|
||||
IXMLDOMDocument *doc;
|
||||
|
@ -7186,6 +7208,7 @@ START_TEST(domdoc)
|
|||
test_default_properties();
|
||||
test_selectSingleNode();
|
||||
test_events();
|
||||
test_createProcessingInstruction();
|
||||
|
||||
CoUninitialize();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue