From 604861e520d2d6579674a1c2bd5e59cb10f7ecd2 Mon Sep 17 00:00:00 2001 From: Arseny Kapoulkine Date: Tue, 10 Mar 2015 09:03:22 -0700 Subject: Escape ?> sequence in PI value during printing This prevents malformed PI value from breaking the document structure. --- tests/test_write.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'tests/test_write.cpp') diff --git a/tests/test_write.cpp b/tests/test_write.cpp index da83745..59cdb3e 100644 --- a/tests/test_write.cpp +++ b/tests/test_write.cpp @@ -115,6 +115,25 @@ TEST(write_pi_null) CHECK_NODE(doc, STR("")); } +TEST(write_pi_invalid) +{ + xml_document doc; + xml_node node = doc.append_child(node_pi); + + node.set_name(STR("test")); + node.set_value(STR("?")); + + CHECK_NODE(doc, STR("")); + + node.set_value(STR("?>")); + + CHECK_NODE(doc, STR("?>")); + + node.set_value(STR("")); + + CHECK_NODE(doc, STR("?>")); +} + TEST_XML_FLAGS(write_declaration, "", parse_declaration | parse_fragment) { CHECK_NODE(doc, STR("")); -- cgit v1.2.3