Commit 2a6abc24 authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

msxml3: Use element name length passed to content handler.

parent 9ae103f7
......@@ -155,16 +155,16 @@ static void close_element_starttag(const mxwriter *This)
xmlOutputBufferWriteString(This->buffer, ">");
}
static void set_element_name(mxwriter *This, const WCHAR *name)
static void set_element_name(mxwriter *This, const WCHAR *name, int len)
{
SysFreeString(This->element);
This->element = SysAllocString(name);
This->element = name ? SysAllocStringLen(name, len) : NULL;
}
static inline HRESULT flush_output_buffer(mxwriter *This)
{
close_element_starttag(This);
set_element_name(This, NULL);
set_element_name(This, NULL, 0);
xmlOutputBufferFlush(This->buffer);
return write_data_to_stream(This);
}
......@@ -763,10 +763,11 @@ static HRESULT WINAPI mxwriter_saxcontent_startElement(
return E_INVALIDARG;
close_element_starttag(This);
set_element_name(This, QName ? QName : emptyW);
set_element_name(This, QName ? QName : emptyW,
QName ? nQName : 0);
xmlOutputBufferWriteString(This->buffer, "<");
s = xmlchar_from_wchar(QName);
s = xmlchar_from_wcharn(QName, nQName);
xmlOutputBufferWriteString(This->buffer, (char*)s);
heap_free(s);
......@@ -843,7 +844,7 @@ static HRESULT WINAPI mxwriter_saxcontent_endElement(
}
heap_free(s);
set_element_name(This, NULL);
set_element_name(This, NULL, 0);
return S_OK;
}
......@@ -860,7 +861,7 @@ static HRESULT WINAPI mxwriter_saxcontent_characters(
if (!chars) return E_INVALIDARG;
close_element_starttag(This);
set_element_name(This, NULL);
set_element_name(This, NULL, 0);
if (nchars)
{
......
......@@ -1720,27 +1720,44 @@ static void test_mxwriter_startendelement(void)
VariantClear(&dest);
hr = ISAXContentHandler_endElement(content, NULL, 0, NULL, 0, _bstr_("a:b"), 3);
ok(hr == E_INVALIDARG, "got %08x\n", hr);
EXPECT_HR(hr, E_INVALIDARG);
hr = ISAXContentHandler_endElement(content, NULL, 0, _bstr_("b"), 1, _bstr_("a:b"), 3);
ok(hr == E_INVALIDARG, "got %08x\n", hr);
EXPECT_HR(hr, E_INVALIDARG);
/* only local name is an error too */
hr = ISAXContentHandler_endElement(content, NULL, 0, _bstr_("b"), 1, NULL, 0);
ok(hr == E_INVALIDARG, "got %08x\n", hr);
EXPECT_HR(hr, E_INVALIDARG);
hr = ISAXContentHandler_endElement(content, _bstr_(""), 0, _bstr_(""), 0, _bstr_("b"), 1);
ok(hr == S_OK, "got %08x\n", hr);
EXPECT_HR(hr, S_OK);
V_VT(&dest) = VT_EMPTY;
hr = IMXWriter_get_output(writer, &dest);
ok(hr == S_OK, "got %08x\n", hr);
EXPECT_HR(hr, S_OK);
ok(V_VT(&dest) == VT_BSTR, "got %d\n", V_VT(&dest));
ok(!lstrcmpW(_bstr_("<><b></b>"), V_BSTR(&dest)), "got wrong content %s\n", wine_dbgstr_w(V_BSTR(&dest)));
VariantClear(&dest);
hr = ISAXContentHandler_endDocument(content);
ok(hr == S_OK, "got %08x\n", hr);
EXPECT_HR(hr, S_OK);
V_VT(&dest) = VT_EMPTY;
hr = IMXWriter_put_output(writer, dest);
EXPECT_HR(hr, S_OK);
hr = ISAXContentHandler_startDocument(content);
EXPECT_HR(hr, S_OK);
hr = ISAXContentHandler_startElement(content, _bstr_(""), 0, _bstr_(""), 0, _bstr_("abcdef"), 3, NULL);
EXPECT_HR(hr, S_OK);
V_VT(&dest) = VT_EMPTY;
hr = IMXWriter_get_output(writer, &dest);
EXPECT_HR(hr, S_OK);
ok(V_VT(&dest) == VT_BSTR, "got %d\n", V_VT(&dest));
ok(!lstrcmpW(_bstr_("<abc>"), V_BSTR(&dest)), "got wrong content %s\n", wine_dbgstr_w(V_BSTR(&dest)));
VariantClear(&dest);
ISAXContentHandler_Release(content);
IMXWriter_Release(writer);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment