Signed-off-by: Daniel Lehman dlehman25@gmail.com --- dlls/msxml3/tests/domdoc.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+)
diff --git a/dlls/msxml3/tests/domdoc.c b/dlls/msxml3/tests/domdoc.c index 9e9789ebd9a..d98a87f6d9c 100644 --- a/dlls/msxml3/tests/domdoc.c +++ b/dlls/msxml3/tests/domdoc.c @@ -8594,6 +8594,31 @@ static void test_createProcessingInstruction(void) hr = IXMLDOMDocument_createProcessingInstruction(doc, _bstr_("xml"), _bstr_("version="1.0" encoding="windows-1252" dummy="value""), &pi); todo_wine ok(hr == XML_E_UNEXPECTED_ATTRIBUTE, "got 0x%08x\n", hr); + hr = IXMLDOMDocument_createProcessingInstruction(doc, NULL, _bstr_("version="1.0" encoding="UTF-8""), &pi); + ok(hr == E_FAIL, "got 0x%08x\n", hr); + hr = IXMLDOMDocument_createProcessingInstruction(doc, _bstr_("xml"), NULL, &pi); +todo_wine + ok(hr == XML_E_XMLDECLSYNTAX, "got 0x%08x\n", hr); + hr = IXMLDOMDocument_createProcessingInstruction(doc, _bstr_("xml"), _bstr_("version="1.0" encoding=UTF-8"), &pi); +todo_wine + ok(hr == XML_E_MISSINGQUOTE, "got 0x%08x\n", hr); + hr = IXMLDOMDocument_createProcessingInstruction(doc, _bstr_("xml"), _bstr_("version="1.0" encoding='UTF-8""), &pi); +todo_wine + ok(hr == XML_E_BADCHARINSTRING, "got 0x%08x\n", hr); + hr = IXMLDOMDocument_createProcessingInstruction(doc, _bstr_("xml"), _bstr_("version="1.0" encoding="UTF-8"), &pi); +todo_wine + ok(hr == XML_E_BADCHARINSTRING, "got 0x%08x\n", hr); + hr = IXMLDOMDocument_createProcessingInstruction(doc, _bstr_("xml"), _bstr_("version="1.0" encoding='UTF-8'"), &pi); + ok(hr == S_OK, "got 0x%08x\n", hr); + hr = IXMLDOMProcessingInstruction_QueryInterface(pi, &IID_IXMLDOMNode, (void **)&node); + node_map = NULL; + ok(hr == S_OK, "got 0x%08x\n", hr); + hr = IXMLDOMNode_get_attributes(node, &node_map); +todo_wine + ok(hr == S_OK, "got 0x%08x\n", hr); + if (node_map) IXMLDOMNamedNodeMap_Release(node_map); + IXMLDOMNode_Release(node); + IXMLDOMProcessingInstruction_Release(pi);
/* test for BSTR handling, pass broken BSTR */ memcpy(&buff[2], L"test", 5 * sizeof(WCHAR));
Signed-off-by: Daniel Lehman dlehman25@gmail.com --- dlls/msxml3/domdoc.c | 9 +++----- dlls/msxml3/msxml_private.h | 2 ++ dlls/msxml3/pi.c | 41 +++++++++++++++++++++++-------------- dlls/msxml3/tests/domdoc.c | 8 +++++--- 4 files changed, 36 insertions(+), 24 deletions(-)
diff --git a/dlls/msxml3/domdoc.c b/dlls/msxml3/domdoc.c index e8b5445df19..566bfa06798 100644 --- a/dlls/msxml3/domdoc.c +++ b/dlls/msxml3/domdoc.c @@ -1890,13 +1890,10 @@ static HRESULT WINAPI domdoc_createProcessingInstruction( hr = IXMLDOMDocument3_createNode(iface, type, target, NULL, &node); if (hr == S_OK) { - xmlnode *node_obj; - /* this is to bypass check in ::put_data() that blocks "<?xml" PIs */ - node_obj = get_node_obj(node); - hr = node_set_content(node_obj, data); - - IXMLDOMNode_QueryInterface(node, &IID_IXMLDOMProcessingInstruction, (void**)pi); + hr = dom_pi_put_xml_decl(node, data); + if (SUCCEEDED(hr)) + hr = IXMLDOMNode_QueryInterface(node, &IID_IXMLDOMProcessingInstruction, (void**)pi); IXMLDOMNode_Release(node); }
diff --git a/dlls/msxml3/msxml_private.h b/dlls/msxml3/msxml_private.h index f16040f3542..3d3cdc60f33 100644 --- a/dlls/msxml3/msxml_private.h +++ b/dlls/msxml3/msxml_private.h @@ -281,6 +281,8 @@ extern BSTR EnsureCorrectEOL(BSTR) DECLSPEC_HIDDEN;
extern xmlChar* tagName_to_XPath(const BSTR tagName) DECLSPEC_HIDDEN;
+extern HRESULT dom_pi_put_xml_decl(IXMLDOMNode *node, BSTR data) DECLSPEC_HIDDEN; + #ifdef SONAME_LIBXSLT # include <libxslt/documents.h> extern xmlDocPtr xslt_doc_default_loader(const xmlChar *uri, xmlDictPtr dict, int options, diff --git a/dlls/msxml3/pi.c b/dlls/msxml3/pi.c index 606d8dc3571..d0626c7b0dd 100644 --- a/dlls/msxml3/pi.c +++ b/dlls/msxml3/pi.c @@ -439,25 +439,11 @@ static HRESULT WINAPI dom_pi_get_attributes( if (hr != S_OK) return hr;
if (!strcmpW(name, xmlW)) - { - if (!This->node.node->properties) - { - hr = parse_xml_decl(This->node.node); - if (hr != S_OK) - { - SysFreeString(name); - return S_FALSE; - } - } - *map = create_nodemap(This->node.node, &dom_pi_attr_map); - SysFreeString(name); - return S_OK; - }
SysFreeString(name);
- return S_FALSE; + return *map ? S_OK : S_FALSE; }
static HRESULT WINAPI dom_pi_insertBefore( @@ -766,6 +752,31 @@ static HRESULT WINAPI dom_pi_put_data( return node_set_content(&This->node, data); }
+HRESULT dom_pi_put_xml_decl(IXMLDOMNode *node, BSTR data) +{ + static const WCHAR xmlW[] = {'x','m','l',0}; + xmlnode *node_obj; + HRESULT hr; + BSTR name; + + node_obj = get_node_obj(node); + hr = node_set_content(node_obj, data); + if (FAILED(hr)) + return hr; + + hr = node_get_nodeName(node_obj, &name); + if (FAILED(hr)) + return hr; + + if (!strcmpW(name, xmlW) && !node_obj->node->properties) + hr = parse_xml_decl(node_obj->node); + else + hr = S_OK; + + SysFreeString(name); + return hr; +} + static const struct IXMLDOMProcessingInstructionVtbl dom_pi_vtbl = { dom_pi_QueryInterface, diff --git a/dlls/msxml3/tests/domdoc.c b/dlls/msxml3/tests/domdoc.c index d98a87f6d9c..81ee8dcb52d 100644 --- a/dlls/msxml3/tests/domdoc.c +++ b/dlls/msxml3/tests/domdoc.c @@ -8592,7 +8592,6 @@ static void test_createProcessingInstruction(void) doc = create_document(&IID_IXMLDOMDocument);
hr = IXMLDOMDocument_createProcessingInstruction(doc, _bstr_("xml"), _bstr_("version="1.0" encoding="windows-1252" dummy="value""), &pi); -todo_wine ok(hr == XML_E_UNEXPECTED_ATTRIBUTE, "got 0x%08x\n", hr); hr = IXMLDOMDocument_createProcessingInstruction(doc, NULL, _bstr_("version="1.0" encoding="UTF-8""), &pi); ok(hr == E_FAIL, "got 0x%08x\n", hr); @@ -8600,7 +8599,6 @@ todo_wine todo_wine ok(hr == XML_E_XMLDECLSYNTAX, "got 0x%08x\n", hr); hr = IXMLDOMDocument_createProcessingInstruction(doc, _bstr_("xml"), _bstr_("version="1.0" encoding=UTF-8"), &pi); -todo_wine ok(hr == XML_E_MISSINGQUOTE, "got 0x%08x\n", hr); hr = IXMLDOMDocument_createProcessingInstruction(doc, _bstr_("xml"), _bstr_("version="1.0" encoding='UTF-8""), &pi); todo_wine @@ -8608,17 +8606,21 @@ todo_wine hr = IXMLDOMDocument_createProcessingInstruction(doc, _bstr_("xml"), _bstr_("version="1.0" encoding="UTF-8"), &pi); todo_wine ok(hr == XML_E_BADCHARINSTRING, "got 0x%08x\n", hr); + pi = NULL; hr = IXMLDOMDocument_createProcessingInstruction(doc, _bstr_("xml"), _bstr_("version="1.0" encoding='UTF-8'"), &pi); +todo_wine ok(hr == S_OK, "got 0x%08x\n", hr); +if (pi) +{ hr = IXMLDOMProcessingInstruction_QueryInterface(pi, &IID_IXMLDOMNode, (void **)&node); node_map = NULL; ok(hr == S_OK, "got 0x%08x\n", hr); hr = IXMLDOMNode_get_attributes(node, &node_map); -todo_wine ok(hr == S_OK, "got 0x%08x\n", hr); if (node_map) IXMLDOMNamedNodeMap_Release(node_map); IXMLDOMNode_Release(node); IXMLDOMProcessingInstruction_Release(pi); +}
/* test for BSTR handling, pass broken BSTR */ memcpy(&buff[2], L"test", 5 * sizeof(WCHAR));
Signed-off-by: Daniel Lehman dlehman25@gmail.com --- dlls/msxml3/pi.c | 7 ++++--- dlls/msxml3/tests/domdoc.c | 6 +----- 2 files changed, 5 insertions(+), 8 deletions(-)
diff --git a/dlls/msxml3/pi.c b/dlls/msxml3/pi.c index d0626c7b0dd..95e6cf34e1c 100644 --- a/dlls/msxml3/pi.c +++ b/dlls/msxml3/pi.c @@ -290,7 +290,7 @@ static HRESULT WINAPI dom_pi_get_nextSibling(
static HRESULT xml_get_value(xmlChar **p, xmlChar **value) { - xmlChar *v; + xmlChar *v, q; int len;
while (isspace(**p)) *p += 1; @@ -298,11 +298,12 @@ static HRESULT xml_get_value(xmlChar **p, xmlChar **value) *p += 1;
while (isspace(**p)) *p += 1; - if (**p != '"') return XML_E_MISSINGQUOTE; + if (**p != '"' && **p != ''') return XML_E_MISSINGQUOTE; + q = **p; *p += 1;
v = *p; - while (**p && **p != '"') *p += 1; + while (**p && **p != q) *p += 1; if (!**p) return XML_E_EXPECTINGCLOSEQUOTE; len = *p - v; if (!len) return XML_E_MISSINGNAME; diff --git a/dlls/msxml3/tests/domdoc.c b/dlls/msxml3/tests/domdoc.c index 81ee8dcb52d..e1f71bf5445 100644 --- a/dlls/msxml3/tests/domdoc.c +++ b/dlls/msxml3/tests/domdoc.c @@ -8608,19 +8608,15 @@ todo_wine ok(hr == XML_E_BADCHARINSTRING, "got 0x%08x\n", hr); pi = NULL; hr = IXMLDOMDocument_createProcessingInstruction(doc, _bstr_("xml"), _bstr_("version="1.0" encoding='UTF-8'"), &pi); -todo_wine ok(hr == S_OK, "got 0x%08x\n", hr); -if (pi) -{ hr = IXMLDOMProcessingInstruction_QueryInterface(pi, &IID_IXMLDOMNode, (void **)&node); node_map = NULL; ok(hr == S_OK, "got 0x%08x\n", hr); hr = IXMLDOMNode_get_attributes(node, &node_map); ok(hr == S_OK, "got 0x%08x\n", hr); - if (node_map) IXMLDOMNamedNodeMap_Release(node_map); + IXMLDOMNamedNodeMap_Release(node_map); IXMLDOMNode_Release(node); IXMLDOMProcessingInstruction_Release(pi); -}
/* test for BSTR handling, pass broken BSTR */ memcpy(&buff[2], L"test", 5 * sizeof(WCHAR));
Signed-off-by: Daniel Lehman dlehman25@gmail.com --- dlls/msxml3/pi.c | 3 +++ dlls/msxml3/tests/domdoc.c | 1 - 2 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/dlls/msxml3/pi.c b/dlls/msxml3/pi.c index 95e6cf34e1c..f597cb7176a 100644 --- a/dlls/msxml3/pi.c +++ b/dlls/msxml3/pi.c @@ -760,6 +760,9 @@ HRESULT dom_pi_put_xml_decl(IXMLDOMNode *node, BSTR data) HRESULT hr; BSTR name;
+ if (!data) + return XML_E_XMLDECLSYNTAX; + node_obj = get_node_obj(node); hr = node_set_content(node_obj, data); if (FAILED(hr)) diff --git a/dlls/msxml3/tests/domdoc.c b/dlls/msxml3/tests/domdoc.c index e1f71bf5445..dbd56e11f68 100644 --- a/dlls/msxml3/tests/domdoc.c +++ b/dlls/msxml3/tests/domdoc.c @@ -8596,7 +8596,6 @@ static void test_createProcessingInstruction(void) hr = IXMLDOMDocument_createProcessingInstruction(doc, NULL, _bstr_("version="1.0" encoding="UTF-8""), &pi); ok(hr == E_FAIL, "got 0x%08x\n", hr); hr = IXMLDOMDocument_createProcessingInstruction(doc, _bstr_("xml"), NULL, &pi); -todo_wine ok(hr == XML_E_XMLDECLSYNTAX, "got 0x%08x\n", hr); hr = IXMLDOMDocument_createProcessingInstruction(doc, _bstr_("xml"), _bstr_("version="1.0" encoding=UTF-8"), &pi); ok(hr == XML_E_MISSINGQUOTE, "got 0x%08x\n", hr);
Signed-off-by: Daniel Lehman dlehman25@gmail.com --- dlls/msxml3/pi.c | 2 +- dlls/msxml3/tests/domdoc.c | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-)
diff --git a/dlls/msxml3/pi.c b/dlls/msxml3/pi.c index f597cb7176a..06849d6f092 100644 --- a/dlls/msxml3/pi.c +++ b/dlls/msxml3/pi.c @@ -304,7 +304,7 @@ static HRESULT xml_get_value(xmlChar **p, xmlChar **value)
v = *p; while (**p && **p != q) *p += 1; - if (!**p) return XML_E_EXPECTINGCLOSEQUOTE; + if (!**p) return XML_E_BADCHARINSTRING; len = *p - v; if (!len) return XML_E_MISSINGNAME; *p += 1; diff --git a/dlls/msxml3/tests/domdoc.c b/dlls/msxml3/tests/domdoc.c index dbd56e11f68..70e2da89a2f 100644 --- a/dlls/msxml3/tests/domdoc.c +++ b/dlls/msxml3/tests/domdoc.c @@ -8600,10 +8600,8 @@ static void test_createProcessingInstruction(void) hr = IXMLDOMDocument_createProcessingInstruction(doc, _bstr_("xml"), _bstr_("version="1.0" encoding=UTF-8"), &pi); ok(hr == XML_E_MISSINGQUOTE, "got 0x%08x\n", hr); hr = IXMLDOMDocument_createProcessingInstruction(doc, _bstr_("xml"), _bstr_("version="1.0" encoding='UTF-8""), &pi); -todo_wine ok(hr == XML_E_BADCHARINSTRING, "got 0x%08x\n", hr); hr = IXMLDOMDocument_createProcessingInstruction(doc, _bstr_("xml"), _bstr_("version="1.0" encoding="UTF-8"), &pi); -todo_wine ok(hr == XML_E_BADCHARINSTRING, "got 0x%08x\n", hr); pi = NULL; hr = IXMLDOMDocument_createProcessingInstruction(doc, _bstr_("xml"), _bstr_("version="1.0" encoding='UTF-8'"), &pi);