fix: #320: " and ' encoding must also apply for PCDATA

This commit is contained in:
pamapa 2020-01-12 11:52:49 +01:00
parent f9bd700b77
commit a4a94f7f3e
2 changed files with 5 additions and 5 deletions

View File

@ -1871,7 +1871,7 @@ PUGI__NS_BEGIN
{ {
3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 3, 3, 2, 3, 3, // 0-15 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 3, 3, 2, 3, 3, // 0-15
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // 16-31 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // 16-31
0, 0, 2, 0, 0, 0, 3, 2, 0, 0, 0, 0, 0, 16, 16, 0, // 32-47 0, 0, 3, 0, 0, 0, 3, 3, 0, 0, 0, 0, 0, 16, 16, 0, // 32-47
24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 0, 0, 3, 0, 1, 0, // 48-63 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 0, 0, 3, 0, 1, 0, // 48-63
0, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, // 64-79 0, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, // 64-79

View File

@ -193,8 +193,8 @@ TEST_XML(write_escape, "<node attr=''>text</node>")
doc.child(STR("node")).attribute(STR("attr")) = STR("<>'\"&\x04\r\n\t"); doc.child(STR("node")).attribute(STR("attr")) = STR("<>'\"&\x04\r\n\t");
doc.child(STR("node")).first_child().set_value(STR("<>'\"&\x04\r\n\t")); doc.child(STR("node")).first_child().set_value(STR("<>'\"&\x04\r\n\t"));
CHECK_NODE(doc, STR("<node attr=\"&lt;>&apos;&quot;&amp;&#04;&#13;&#10;&#09;\">&lt;&gt;'\"&amp;&#04;\r\n\t</node>")); CHECK_NODE(doc, STR("<node attr=\"&lt;>&apos;&quot;&amp;&#04;&#13;&#10;&#09;\">&lt;&gt;&apos;&quot;&amp;&#04;\r\n\t</node>"));
CHECK_NODE_EX(doc, STR("<node attr='&lt;>&apos;&quot;&amp;&#04;&#13;&#10;&#09;'>&lt;&gt;'\"&amp;&#04;\r\n\t</node>"), STR(""), format_raw | format_attribute_single_quote); CHECK_NODE_EX(doc, STR("<node attr='&lt;>&apos;&quot;&amp;&#04;&#13;&#10;&#09;'>&lt;&gt;&apos;&quot;&amp;&#04;\r\n\t</node>"), STR(""), format_raw | format_attribute_single_quote);
} }
TEST_XML(write_escape_roundtrip, "<node attr=''>text</node>") TEST_XML(write_escape_roundtrip, "<node attr=''>text</node>")
@ -208,8 +208,8 @@ TEST_XML(write_escape_roundtrip, "<node attr=''>text</node>")
// Note: this string is almost identical to the string from write_escape with the exception of \r // Note: this string is almost identical to the string from write_escape with the exception of \r
// \r in PCDATA doesn't roundtrip because it has to go through newline conversion (which could be disabled, but is active by default) // \r in PCDATA doesn't roundtrip because it has to go through newline conversion (which could be disabled, but is active by default)
CHECK_NODE(doc, STR("<node attr=\"&lt;>&apos;&quot;&amp;&#04;&#13;&#10;&#09;\">&lt;&gt;'\"&amp;&#04;\n\t</node>")); CHECK_NODE(doc, STR("<node attr=\"&lt;>&apos;&quot;&amp;&#04;&#13;&#10;&#09;\">&lt;&gt;&apos;&quot;&amp;&#04;\n\t</node>"));
CHECK_NODE_EX(doc, STR("<node attr='&lt;>&apos;&quot;&amp;&#04;&#13;&#10;&#09;'>&lt;&gt;'\"&amp;&#04;\n\t</node>"), STR(""), format_raw | format_attribute_single_quote); CHECK_NODE_EX(doc, STR("<node attr='&lt;>&apos;&quot;&amp;&#04;&#13;&#10;&#09;'>&lt;&gt;&apos;&quot;&amp;&#04;\n\t</node>"), STR(""), format_raw | format_attribute_single_quote);
} }
TEST_XML(write_escape_unicode, "<node attr='&#x3c00;'/>") TEST_XML(write_escape_unicode, "<node attr='&#x3c00;'/>")