diff --git a/dlls/msxml3/tests/domdoc.c b/dlls/msxml3/tests/domdoc.c index 85d2bc4c54d..4b894b000b9 100644 --- a/dlls/msxml3/tests/domdoc.c +++ b/dlls/msxml3/tests/domdoc.c @@ -12185,6 +12185,9 @@ static void test_put_data(void) WCHAR buff[100], *data; IXMLDOMDocument *doc; DOMNodeType *type; + IXMLDOMText *text; + IXMLDOMNode *node; + VARIANT v; BSTR get_data; HRESULT hr; @@ -12199,9 +12202,6 @@ static void test_put_data(void) type = put_data_types; while (*type != NODE_INVALID) { - IXMLDOMNode *node; - VARIANT v; - V_VT(&v) = VT_I2; V_I2(&v) = *type; @@ -12213,8 +12213,6 @@ static void test_put_data(void) { case NODE_TEXT: { - IXMLDOMText *text; - hr = IXMLDOMNode_QueryInterface(node, &IID_IXMLDOMText, (void**)&text); EXPECT_HR(hr, S_OK); hr = IXMLDOMText_put_data(text, data); @@ -12284,6 +12282,32 @@ static void test_put_data(void) type++; } + /* \r\n sequence is never escaped */ + V_VT(&v) = VT_I2; + V_I2(&v) = NODE_TEXT; + + hr = IXMLDOMDocument_createNode(doc, v, _bstr_("name"), NULL, &node); + ok(hr == S_OK, "got 0x%08x\n", hr); + + IXMLDOMNode_QueryInterface(node, &IID_IXMLDOMText, (void**)&text); + + hr = IXMLDOMText_put_data(text, _bstr_("\r\n")); + ok(hr == S_OK, "got 0x%08x\n", hr); + + hr = IXMLDOMText_get_data(text, &get_data); + ok(hr == S_OK, "got 0x%08x\n", hr); +todo_wine + ok(!lstrcmpW(get_data, _bstr_("\n")), "got %s\n", wine_dbgstr_w(get_data)); + SysFreeString(get_data); + + hr = IXMLDOMText_get_xml(text, &get_data); + ok(hr == S_OK, "got 0x%08x\n", hr); + ok(!lstrcmpW(get_data, _bstr_("\r\n")), "got %s\n", wine_dbgstr_w(get_data)); + SysFreeString(get_data); + + IXMLDOMText_Release(text); + IXMLDOMNode_Release(node); + IXMLDOMDocument_Release(doc); free_bstrs(); } diff --git a/dlls/msxml3/text.c b/dlls/msxml3/text.c index 6fb29f9e3f9..e9c64c17bf7 100644 --- a/dlls/msxml3/text.c +++ b/dlls/msxml3/text.c @@ -26,6 +26,7 @@ #include #ifdef HAVE_LIBXML2 # include +# include # include #endif @@ -55,6 +56,11 @@ static inline domtext *impl_from_IXMLDOMText( IXMLDOMText *iface ) return CONTAINING_RECORD(iface, domtext, IXMLDOMText_iface); } +static void domtext_reset_noenc(domtext *This) +{ + This->node.node->name = NULL; +} + static HRESULT WINAPI domtext_QueryInterface( IXMLDOMText *iface, REFIID riid, @@ -182,6 +188,7 @@ static HRESULT WINAPI domtext_put_nodeValue( TRACE("(%p)->(%s)\n", This, debugstr_variant(&value)); + domtext_reset_noenc(This); return node_put_value(&This->node, &value); } @@ -371,6 +378,7 @@ static HRESULT WINAPI domtext_put_text( { domtext *This = impl_from_IXMLDOMText( iface ); TRACE("(%p)->(%s)\n", This, debugstr_w(p)); + domtext_reset_noenc(This); return node_put_text( &This->node, p ); } @@ -608,7 +616,14 @@ static HRESULT WINAPI domtext_put_data( BSTR data) { domtext *This = impl_from_IXMLDOMText( iface ); + static WCHAR rnW[] = {'\r','\n',0}; + TRACE("(%p)->(%s)\n", This, debugstr_w(data)); + + if (data && !strcmpW(rnW, data)) + This->node.node->name = xmlStringTextNoenc; + else + domtext_reset_noenc(This); return node_set_content(&This->node, data); }