summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorArseny Kapoulkine <arseny.kapoulkine@gmail.com>2015-03-10 09:03:22 -0700
committerArseny Kapoulkine <arseny.kapoulkine@gmail.com>2015-03-10 09:03:22 -0700
commit604861e520d2d6579674a1c2bd5e59cb10f7ecd2 (patch)
tree4deb62f1bae976c4373a4f9356fb3ce5f27dca34 /tests
parent23060d095447ca7c47a9c0698ec731197cebc80b (diff)
Escape ?> sequence in PI value during printing
This prevents malformed PI value from breaking the document structure.
Diffstat (limited to 'tests')
-rw-r--r--tests/test_write.cpp19
1 files changed, 19 insertions, 0 deletions
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("<?:anonymous value?>"));
}
+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("<?test ?" "?>"));
+
+ node.set_value(STR("?>"));
+
+ CHECK_NODE(doc, STR("<?test ? >?>"));
+
+ node.set_value(STR("<?foo?>"));
+
+ CHECK_NODE(doc, STR("<?test <?foo? >?>"));
+}
+
TEST_XML_FLAGS(write_declaration, "<?xml version='2.0'?>", parse_declaration | parse_fragment)
{
CHECK_NODE(doc, STR("<?xml version=\"2.0\"?>"));