summaryrefslogtreecommitdiffstats
path: root/src/xplist.c
diff options
context:
space:
mode:
authorGravatar Martin Szulecki2014-05-27 10:44:05 +0200
committerGravatar Martin Szulecki2014-05-27 10:44:05 +0200
commit63abebfba51a96e6862cd84e8a768b2c1f6ec834 (patch)
treeed7d18de9edc5ca61e21e286e0c1b8b47bc16e2e /src/xplist.c
parent06e7233b6ba0aa19b68b993420b90de277e10c9b (diff)
downloadlibplist-63abebfba51a96e6862cd84e8a768b2c1f6ec834.tar.gz
libplist-63abebfba51a96e6862cd84e8a768b2c1f6ec834.tar.bz2
xplist: Fix keys not being output correctly if converted to XML entities
Diffstat (limited to 'src/xplist.c')
-rw-r--r--src/xplist.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/xplist.c b/src/xplist.c
index eaa2468..96539a6 100644
--- a/src/xplist.c
+++ b/src/xplist.c
@@ -199,7 +199,7 @@ static void node_to_xml(node_t* node, void *xml_struct)
199 199
200 case PLIST_STRING: 200 case PLIST_STRING:
201 tag = XPLIST_STRING; 201 tag = XPLIST_STRING;
202 val = strdup(node_data->strval); 202 val = strdup((char*) node_data->strval);
203 break; 203 break;
204 204
205 case PLIST_KEY: 205 case PLIST_KEY:
@@ -257,7 +257,7 @@ static void node_to_xml(node_t* node, void *xml_struct)
257 { 257 {
258 xmlNodeAddContent(xstruct->xml, BAD_CAST("\t")); 258 xmlNodeAddContent(xstruct->xml, BAD_CAST("\t"));
259 } 259 }
260 if (node_data->type == PLIST_STRING) { 260 if (node_data->type == PLIST_STRING || node_data->type == PLIST_KEY) {
261 /* make sure we convert the following predefined xml entities */ 261 /* make sure we convert the following predefined xml entities */
262 /* < = &lt; > = &gt; ' = &apos; " = &quot; & = &amp; */ 262 /* < = &lt; > = &gt; ' = &apos; " = &quot; & = &amp; */
263 child_node = xmlNewTextChild(xstruct->xml, NULL, tag, BAD_CAST(val)); 263 child_node = xmlNewTextChild(xstruct->xml, NULL, tag, BAD_CAST(val));
@@ -458,9 +458,15 @@ static void xml_to_node(xmlNodePtr xml_node, plist_t * plist_node)
458 if (!xmlStrcmp(node->name, XPLIST_KEY)) 458 if (!xmlStrcmp(node->name, XPLIST_KEY))
459 { 459 {
460 xmlChar *strval = xmlNodeGetContent(node); 460 xmlChar *strval = xmlNodeGetContent(node);
461 data->strval = strdup((char *) strval); 461 len = strlen((char *) strval);
462 data->type = PLIST_KEY; 462 type = xmlDetectCharEncoding(strval, len);
463 data->length = strlen(data->strval); 463
464 if (XML_CHAR_ENCODING_UTF8 == type || XML_CHAR_ENCODING_ASCII == type || XML_CHAR_ENCODING_NONE == type)
465 {
466 data->strval = strdup((char *) strval);
467 data->type = PLIST_KEY;
468 data->length = strlen(data->strval);
469 }
464 xmlFree(strval); 470 xmlFree(strval);
465 continue; 471 continue;
466 } 472 }