Signed-off-by: Jeff Smith whydoubt@gmail.com --- dlls/xmllite/reader.c | 23 ++++++++++++------- dlls/xmllite/tests/reader.c | 46 +++++++++++++++++++++++++++++++++++-- 2 files changed, 59 insertions(+), 10 deletions(-)
diff --git a/dlls/xmllite/reader.c b/dlls/xmllite/reader.c index 88db0df4c2..3875676f01 100644 --- a/dlls/xmllite/reader.c +++ b/dlls/xmllite/reader.c @@ -1965,7 +1965,7 @@ static HRESULT reader_parse_qname(xmlreader *reader, strval *prefix, strval *loc static HRESULT reader_parse_dtd(xmlreader *reader) { static const WCHAR doctypeW[] = {'<','!','D','O','C','T','Y','P','E',0}; - strval name; + strval prefix, local, qname; WCHAR *cur; HRESULT hr;
@@ -1980,7 +1980,7 @@ static HRESULT reader_parse_dtd(xmlreader *reader) if (!reader_skipspaces(reader)) return WC_E_WHITESPACE;
/* name */ - hr = reader_parse_name(reader, &name); + hr = reader_parse_qname(reader, &prefix, &local, &qname); if (FAILED(hr)) return WC_E_DECLDOCTYPE;
reader_skipspaces(reader); @@ -2002,9 +2002,12 @@ static HRESULT reader_parse_dtd(xmlreader *reader)
reader->nodetype = XmlNodeType_DocumentType; reader_free_strvalued(reader, &reader->empty_element.localname); - reader_strvaldup(reader, &name, &reader->empty_element.localname); - reader_free_strvalued(reader, &reader->empty_element.qname); - reader_strvaldup(reader, &name, &reader->empty_element.qname); + reader_strvaldup(reader, &local, &reader->empty_element.localname); + if (prefix.len) + { + reader_strvaldup(reader, &prefix, &reader->empty_element.prefix); + reader_strvaldup(reader, &qname, &reader->empty_element.qname); + }
return S_OK; } @@ -3138,9 +3141,13 @@ static HRESULT WINAPI xmlreader_GetQualifiedName(IXmlReader* iface, LPCWSTR *nam } break; case XmlNodeType_DocumentType: - *name = This->empty_element.qname.str; - *len = This->empty_element.qname.len; - break; + if (This->empty_element.prefix.len) + { + *name = This->empty_element.qname.str; + *len = This->empty_element.qname.len; + break; + } + /* fallthrough */ case XmlNodeType_XmlDeclaration: case XmlNodeType_ProcessingInstruction: *name = This->empty_element.localname.str; diff --git a/dlls/xmllite/tests/reader.c b/dlls/xmllite/tests/reader.c index 2a6d8a053c..a928456571 100644 --- a/dlls/xmllite/tests/reader.c +++ b/dlls/xmllite/tests/reader.c @@ -1315,7 +1315,6 @@ static void test_read_public_dtd(void) move_to_element(reader); name = reader_name(reader, "testdtd"); qname = reader_qname(reader, "testdtd"); -todo_wine ok(name == qname, "name != qname\n");
IXmlReader_Release(reader); @@ -1362,7 +1361,6 @@ static void test_read_system_dtd(void) move_to_element(reader); name = reader_name(reader, "testdtd"); qname = reader_qname(reader, "testdtd"); -todo_wine ok(name == qname, "name != qname\n");
read_node(reader, XmlNodeType_Comment); @@ -1370,6 +1368,49 @@ todo_wine IXmlReader_Release(reader); }
+static const char test_system_dtd_ns[] = + "<!DOCTYPE a:testdtd SYSTEM \"externalid uri\" >"; + +static void test_read_system_dtd_ns(void) +{ + IXmlReader *reader; + XmlNodeType type; + UINT count; + HRESULT hr; + + hr = CreateXmlReader(&IID_IXmlReader, (void**)&reader, NULL); + ok(hr == S_OK, "S_OK, got %08x\n", hr); + + hr = IXmlReader_SetProperty(reader, XmlReaderProperty_DtdProcessing, DtdProcessing_Parse); + ok(hr == S_OK, "got 0x%8x\n", hr); + + set_input_string(reader, test_system_dtd_ns); + + read_node(reader, XmlNodeType_DocumentType); + + count = 0; + hr = IXmlReader_GetAttributeCount(reader, &count); + ok(hr == S_OK, "got %08x\n", hr); + ok(count == 1, "got %d\n", count); + + hr = IXmlReader_MoveToFirstAttribute(reader); + ok(hr == S_OK, "got %08x\n", hr); + + type = XmlNodeType_None; + hr = IXmlReader_GetNodeType(reader, &type); + ok(hr == S_OK, "got %08x\n", hr); + ok(type == XmlNodeType_Attribute, "got %d\n", type); + + reader_name(reader, "SYSTEM"); + reader_value(reader, "externalid uri"); + + move_to_element(reader); + reader_name(reader, "testdtd"); + reader_qname(reader, "a:testdtd"); + + IXmlReader_Release(reader); +} + static struct test_entry element_tests[] = { { "<a/>", "a", "", S_OK }, { "<a />", "a", "", S_OK }, @@ -2652,6 +2693,7 @@ START_TEST(reader) test_read_comment(); test_read_pi(); test_read_system_dtd(); + test_read_system_dtd_ns(); test_read_public_dtd(); test_read_element(); test_isemptyelement();