fix: #320: encoding must not depend on the flag format_attribute_single_quote
This commit is contained in:
parent
41b6ff21c4
commit
f9bd700b77
@ -3930,17 +3930,11 @@ PUGI__NS_BEGIN
|
||||
++s;
|
||||
break;
|
||||
case '"':
|
||||
if (flags & format_attribute_single_quote)
|
||||
writer.write('"');
|
||||
else
|
||||
writer.write('&', 'q', 'u', 'o', 't', ';');
|
||||
writer.write('&', 'q', 'u', 'o', 't', ';');
|
||||
++s;
|
||||
break;
|
||||
case '\'':
|
||||
if (flags & format_attribute_single_quote)
|
||||
writer.write('&', 'a', 'p', 'o', 's', ';');
|
||||
else
|
||||
writer.write('\'');
|
||||
writer.write('&', 'a', 'p', 'o', 's', ';');
|
||||
++s;
|
||||
break;
|
||||
default: // s is not a usual symbol
|
||||
|
||||
@ -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")).first_child().set_value(STR("<>'\"&\x04\r\n\t"));
|
||||
|
||||
CHECK_NODE(doc, STR("<node attr=\"<>'"& 	\"><>'\"&\r\n\t</node>"));
|
||||
CHECK_NODE_EX(doc, STR("<node attr='<>'\"& 	'><>'\"&\r\n\t</node>"), STR(""), format_raw | format_attribute_single_quote);
|
||||
CHECK_NODE(doc, STR("<node attr=\"<>'"& 	\"><>'\"&\r\n\t</node>"));
|
||||
CHECK_NODE_EX(doc, STR("<node attr='<>'"& 	'><>'\"&\r\n\t</node>"), STR(""), format_raw | format_attribute_single_quote);
|
||||
}
|
||||
|
||||
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
|
||||
// \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=\"<>'"& 	\"><>'\"&\n\t</node>"));
|
||||
CHECK_NODE_EX(doc, STR("<node attr='<>'\"& 	'><>'\"&\n\t</node>"), STR(""), format_raw | format_attribute_single_quote);
|
||||
CHECK_NODE(doc, STR("<node attr=\"<>'"& 	\"><>'\"&\n\t</node>"));
|
||||
CHECK_NODE_EX(doc, STR("<node attr='<>'"& 	'><>'\"&\n\t</node>"), STR(""), format_raw | format_attribute_single_quote);
|
||||
}
|
||||
|
||||
TEST_XML(write_escape_unicode, "<node attr='㰀'/>")
|
||||
|
||||
Loading…
Reference in New Issue
Block a user