Commit 9d530346 authored by Hans Leidekker's avatar Hans Leidekker Committed by Alexandre Julliard

webservices: Read past XML declaration and opening bracket in WsReadStartElement.

parent 3e12d29c
......@@ -2654,7 +2654,17 @@ static HRESULT read_node_text( struct reader * );
static HRESULT read_startelement_text( struct reader *reader )
{
HRESULT hr;
if (read_cmp( reader, "<?", 2 ) == S_OK)
{
if ((hr = read_xmldecl( reader )) != S_OK) return hr;
}
read_skip_whitespace( reader );
if (read_cmp( reader, "<", 1 ) == S_OK)
{
if ((hr = read_element_text( reader )) != S_OK) return hr;
}
if (read_cmp( reader, "/>", 2 ) == S_OK)
{
read_skip( reader, 2 );
......@@ -3021,8 +3031,7 @@ static HRESULT read_node_text( struct reader *reader )
else if (reader->state == READER_STATE_CDATA) return read_endcdata( reader );
else if (read_cmp( reader, "<?", 2 ) == S_OK)
{
hr = read_xmldecl( reader );
if (FAILED( hr )) return hr;
if ((hr = read_xmldecl( reader )) != S_OK) return hr;
}
else if (read_cmp( reader, "</", 2 ) == S_OK) return read_endelement_text( reader );
else if (read_cmp( reader, "<![CDATA[", 9 ) == S_OK) return read_startcdata( reader );
......
......@@ -31,7 +31,7 @@ static const char data2[] =
{0xef,0xbb,0xbf,'<','t','e','x','t','>','t','e','s','t','<','/','t','e','x','t','>',0};
static const char data3[] =
"<?xml version=\"1.0\" encoding=\"utf-8\"?>"
"<?xml version=\"1.0\" encoding=\"utf-8\"?> "
"<text>test</TEXT>";
static const char data4[] =
......@@ -928,6 +928,52 @@ static void test_WsReadStartElement(void)
hr = WsReadEndElement( reader, NULL );
ok( hr == WS_E_INVALID_FORMAT, "got %08x\n", hr );
hr = set_input( reader, data3, sizeof(data3) - 1 );
ok( hr == S_OK, "got %08x\n", hr );
hr = WsReadStartElement( reader, NULL );
ok( hr == S_OK, "got %08x\n", hr );
node = NULL;
hr = WsGetReaderNode( reader, &node, NULL );
ok( hr == S_OK, "got %08x\n", hr );
if (node)
{
WS_XML_TEXT_NODE *text = (WS_XML_TEXT_NODE *)node;
ok( text->node.nodeType == WS_XML_NODE_TYPE_TEXT, "got %u\n", text->node.nodeType );
ok( text->text != NULL, "text not set\n" );
if (text->text)
{
WS_XML_UTF8_TEXT *utf8 = (WS_XML_UTF8_TEXT *)text->text;
ok( text->text->textType == WS_XML_TEXT_TYPE_UTF8, "got %u\n", text->text->textType );
ok( utf8->value.length == 4, "got %u\n", utf8->value.length );
ok( !memcmp( utf8->value.bytes, "test", 4 ), "wrong data\n" );
}
}
hr = set_input( reader, " <text>test</text>", sizeof(" <text>test</text>") - 1 );
ok( hr == S_OK, "got %08x\n", hr );
hr = WsReadStartElement( reader, NULL );
ok( hr == S_OK, "got %08x\n", hr );
node = NULL;
hr = WsGetReaderNode( reader, &node, NULL );
ok( hr == S_OK, "got %08x\n", hr );
if (node)
{
WS_XML_TEXT_NODE *text = (WS_XML_TEXT_NODE *)node;
ok( text->node.nodeType == WS_XML_NODE_TYPE_TEXT, "got %u\n", text->node.nodeType );
ok( text->text != NULL, "text not set\n" );
if (text->text)
{
WS_XML_UTF8_TEXT *utf8 = (WS_XML_UTF8_TEXT *)text->text;
ok( text->text->textType == WS_XML_TEXT_TYPE_UTF8, "got %u\n", text->text->textType );
ok( utf8->value.length == 4, "got %u\n", utf8->value.length );
ok( !memcmp( utf8->value.bytes, "test", 4 ), "wrong data\n" );
}
}
WsFreeReader( reader );
}
......
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