Commit 68aeee4d authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

xmllite: Return WC_E_SYNTAX if there is unexpected data in the end of the stream.

parent 6797ee0a
......@@ -2610,14 +2610,17 @@ static HRESULT reader_parse_nextnode(xmlreader *reader)
return reader_parse_content(reader);
case XmlReadInState_MiscEnd:
hr = reader_parse_misc(reader);
if (FAILED(hr)) return hr;
if (hr != S_FALSE) return hr;
if (hr == S_FALSE)
if (*reader_get_ptr(reader))
{
reader->instate = XmlReadInState_Eof;
reader->state = XmlReadState_EndOfFile;
reader->nodetype = XmlNodeType_None;
WARN("found garbage in the end of XML\n");
return WC_E_SYNTAX;
}
reader->instate = XmlReadInState_Eof;
reader->state = XmlReadState_EndOfFile;
reader->nodetype = XmlNodeType_None;
return hr;
case XmlReadInState_Eof:
return S_FALSE;
......
......@@ -2354,6 +2354,7 @@ static void test_eof_state(IXmlReader *reader, BOOL eof)
static void test_endoffile(void)
{
static const char *xml = "<a/>";
static const char *xml_garbageend = "<a/>text";
IXmlReader *reader;
XmlNodeType type;
IStream *stream;
......@@ -2393,6 +2394,33 @@ static void test_endoffile(void)
IStream_Release(stream);
IXmlReader_Release(reader);
hr = CreateXmlReader(&IID_IXmlReader, (void **)&reader, NULL);
ok(hr == S_OK, "S_OK, got %08x\n", hr);
stream = create_stream_on_data(xml_garbageend, strlen(xml_garbageend));
hr = IXmlReader_SetInput(reader, (IUnknown *)stream);
ok(hr == S_OK, "got %08x\n", hr);
IStream_Release(stream);
type = XmlNodeType_None;
hr = IXmlReader_Read(reader, &type);
ok(hr == S_OK, "got %#x\n", hr);
ok(type == XmlNodeType_Element, "Unexpected type %d\n", type);
test_eof_state(reader, FALSE);
type = XmlNodeType_Element;
hr = IXmlReader_Read(reader, &type);
ok(hr == WC_E_SYNTAX, "got %#x\n", hr);
ok(type == XmlNodeType_None, "Unexpected type %d\n", type);
test_eof_state(reader, FALSE);
hr = IXmlReader_SetInput(reader, NULL);
ok(hr == S_OK, "got %08x\n", hr);
IXmlReader_Release(reader);
}
static void test_max_element_depth(void)
......
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