Commit 5e08765f authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

msxml3: Properly handle -1 as length of element qualified name in startElement().

parent 6ab3f1ae
...@@ -536,7 +536,10 @@ static void close_element_starttag(const mxwriter *This) ...@@ -536,7 +536,10 @@ static void close_element_starttag(const mxwriter *This)
static void set_element_name(mxwriter *This, const WCHAR *name, int len) static void set_element_name(mxwriter *This, const WCHAR *name, int len)
{ {
SysFreeString(This->element); SysFreeString(This->element);
This->element = name ? SysAllocStringLen(name, len) : NULL; if (name)
This->element = len != -1 ? SysAllocStringLen(name, len) : SysAllocString(name);
else
This->element = NULL;
} }
static inline HRESULT flush_output_buffer(mxwriter *This) static inline HRESULT flush_output_buffer(mxwriter *This)
......
...@@ -2822,6 +2822,7 @@ static void test_mxwriter_flush(void) ...@@ -2822,6 +2822,7 @@ static void test_mxwriter_flush(void)
HRESULT hr; HRESULT hr;
char *buff; char *buff;
LONG ref; LONG ref;
int len;
hr = CoCreateInstance(&CLSID_MXXMLWriter, NULL, CLSCTX_INPROC_SERVER, hr = CoCreateInstance(&CLSID_MXXMLWriter, NULL, CLSCTX_INPROC_SERVER,
&IID_IMXWriter, (void**)&writer); &IID_IMXWriter, (void**)&writer);
...@@ -2919,9 +2920,10 @@ static void test_mxwriter_flush(void) ...@@ -2919,9 +2920,10 @@ static void test_mxwriter_flush(void)
EXPECT_HR(hr, S_OK); EXPECT_HR(hr, S_OK);
ok(pos2.QuadPart == 0, "expected stream beginning\n"); ok(pos2.QuadPart == 0, "expected stream beginning\n");
buff = HeapAlloc(GetProcessHeap(), 0, 2048); len = 2048;
memset(buff, 'A', 2048); buff = HeapAlloc(GetProcessHeap(), 0, len);
hr = ISAXContentHandler_characters(content, _bstr_(buff), 2048); memset(buff, 'A', len);
hr = ISAXContentHandler_characters(content, _bstr_(buff), len);
EXPECT_HR(hr, S_OK); EXPECT_HR(hr, S_OK);
pos.QuadPart = 0; pos.QuadPart = 0;
...@@ -2965,8 +2967,8 @@ todo_wine ...@@ -2965,8 +2967,8 @@ todo_wine
EXPECT_HR(hr, S_OK); EXPECT_HR(hr, S_OK);
ok(pos2.QuadPart == 0, "expected stream beginning\n"); ok(pos2.QuadPart == 0, "expected stream beginning\n");
memset(buff, 'A', 2048); memset(buff, 'A', len);
hr = ISAXContentHandler_characters(content, _bstr_(buff), 2040); hr = ISAXContentHandler_characters(content, _bstr_(buff), len - 8);
EXPECT_HR(hr, S_OK); EXPECT_HR(hr, S_OK);
pos.QuadPart = 0; pos.QuadPart = 0;
...@@ -2978,6 +2980,28 @@ todo_wine ...@@ -2978,6 +2980,28 @@ todo_wine
hr = ISAXContentHandler_endDocument(content); hr = ISAXContentHandler_endDocument(content);
EXPECT_HR(hr, S_OK); EXPECT_HR(hr, S_OK);
/* test auto-flush function when stream is not set */
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, emptyW, 0, emptyW, 0, _bstr_("a"), -1, NULL);
EXPECT_HR(hr, S_OK);
memset(buff, 'A', len);
hr = ISAXContentHandler_characters(content, _bstr_(buff), len);
EXPECT_HR(hr, S_OK);
V_VT(&dest) = VT_EMPTY;
hr = IMXWriter_get_output(writer, &dest);
EXPECT_HR(hr, S_OK);
len += strlen("<a>");
ok(SysStringLen(V_BSTR(&dest)) == len, "got len=%d, expected %d\n", SysStringLen(V_BSTR(&dest)), len);
VariantClear(&dest);
HeapFree(GetProcessHeap(), 0, buff); HeapFree(GetProcessHeap(), 0, buff);
ISAXContentHandler_Release(content); ISAXContentHandler_Release(content);
IStream_Release(stream); IStream_Release(stream);
...@@ -3382,6 +3406,18 @@ static void test_mxwriter_startendelement(void) ...@@ -3382,6 +3406,18 @@ static void test_mxwriter_startendelement(void)
ok(!lstrcmpW(_bstr_("<abc></abd>"), V_BSTR(&dest)), "got wrong content %s\n", wine_dbgstr_w(V_BSTR(&dest))); ok(!lstrcmpW(_bstr_("<abc></abd>"), V_BSTR(&dest)), "got wrong content %s\n", wine_dbgstr_w(V_BSTR(&dest)));
VariantClear(&dest); VariantClear(&dest);
V_VT(&dest) = VT_EMPTY;
hr = IMXWriter_put_output(writer, dest);
EXPECT_HR(hr, S_OK);
hr = ISAXContentHandler_startElement(content, _bstr_(""), 0, _bstr_(""), 0, _bstr_("a"), -1, 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_("<a>"), V_BSTR(&dest)), "got wrong content %s\n", wine_dbgstr_w(V_BSTR(&dest)));
ISAXContentHandler_Release(content); ISAXContentHandler_Release(content);
IMXWriter_Release(writer); IMXWriter_Release(writer);
free_bstrs(); free_bstrs();
......
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