Commit 874942ec authored by Martin Szulecki's avatar Martin Szulecki Committed by Jonathan Beck

Make sure to convert predefined xml entities in xml output

For string nodes, a set of special characters must be converted to
predefined xml entities. This patch adds an entitiy test case for
this and makes libplist pass it fine by explicitly adding text nodes.
parent 54f1ffb0
......@@ -196,7 +196,12 @@ static void node_to_xml(GNode * node, gpointer xml_struct)
{
xmlNodeAddContent(xstruct->xml, BAD_CAST("\t"));
}
child_node = xmlNewChild(xstruct->xml, NULL, tag, BAD_CAST(val));
if (node_data->type == PLIST_STRING) {
/* make sure we convert the following predefined xml entities */
/* < = &lt; > = &gt; ' = &apos; " = &quot; & = &amp; */
child_node = xmlNewTextChild(xstruct->xml, NULL, tag, BAD_CAST(val));
} else
child_node = xmlNewChild(xstruct->xml, NULL, tag, BAD_CAST(val));
xmlNodeAddContent(xstruct->xml, BAD_CAST("\n"));
g_free(val);
......
......@@ -29,5 +29,7 @@
<key>Some Data</key>
<data>
</data>
<key>Some Entities</key>
<string>hellow world &amp; others &lt;nodes&gt; are &quot;fun!?&apos;</string>
</dict>
</plist>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment