Signed-off-by: Hans Leidekker hans@codeweavers.com --- dlls/webservices/reader.c | 13 +++++++-- dlls/webservices/tests/reader.c | 48 ++++++++++++++++++++++++++++++++- 2 files changed, 58 insertions(+), 3 deletions(-)
diff --git a/dlls/webservices/reader.c b/dlls/webservices/reader.c index f1ce93b7d7..119043f705 100644 --- a/dlls/webservices/reader.c +++ b/dlls/webservices/reader.c @@ -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 ); diff --git a/dlls/webservices/tests/reader.c b/dlls/webservices/tests/reader.c index 5fb81b5dc8..ef6fd8808e 100644 --- a/dlls/webservices/tests/reader.c +++ b/dlls/webservices/tests/reader.c @@ -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 ); }