From f510366388846eae20366fea474e90858fdb3343 Mon Sep 17 00:00:00 2001 From: Martin Szulecki Date: Sat, 9 Jan 2010 10:49:23 +0100 Subject: [PATCH 2/2] 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. --- src/xplist.c | 7 ++++++- test/data/1.plist | 2 ++ 2 files changed, 8 insertions(+), 1 deletions(-) diff --git a/src/xplist.c b/src/xplist.c index 15c9497..ce8dec1 100644 --- a/src/xplist.c +++ b/src/xplist.c @@ -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 */ + /* < = < > = > ' = ' " = " & = & */ + 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); diff --git a/test/data/1.plist b/test/data/1.plist index dfa27b0..c7135e9 100644 --- a/test/data/1.plist +++ b/test/data/1.plist @@ -29,5 +29,7 @@ Some Data + Some Entities + hellow world & others <nodes> are "fun!?' -- 1.6.4.2