Commit 63abebfb authored by Martin Szulecki's avatar Martin Szulecki

xplist: Fix keys not being output correctly if converted to XML entities

parent 06e7233b
...@@ -199,7 +199,7 @@ static void node_to_xml(node_t* node, void *xml_struct) ...@@ -199,7 +199,7 @@ static void node_to_xml(node_t* node, void *xml_struct)
case PLIST_STRING: case PLIST_STRING:
tag = XPLIST_STRING; tag = XPLIST_STRING;
val = strdup(node_data->strval); val = strdup((char*) node_data->strval);
break; break;
case PLIST_KEY: case PLIST_KEY:
...@@ -257,7 +257,7 @@ static void node_to_xml(node_t* node, void *xml_struct) ...@@ -257,7 +257,7 @@ static void node_to_xml(node_t* node, void *xml_struct)
{ {
xmlNodeAddContent(xstruct->xml, BAD_CAST("\t")); xmlNodeAddContent(xstruct->xml, BAD_CAST("\t"));
} }
if (node_data->type == PLIST_STRING) { if (node_data->type == PLIST_STRING || node_data->type == PLIST_KEY) {
/* make sure we convert the following predefined xml entities */ /* make sure we convert the following predefined xml entities */
/* < = &lt; > = &gt; ' = &apos; " = &quot; & = &amp; */ /* < = &lt; > = &gt; ' = &apos; " = &quot; & = &amp; */
child_node = xmlNewTextChild(xstruct->xml, NULL, tag, BAD_CAST(val)); 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,9 +458,15 @@ static void xml_to_node(xmlNodePtr xml_node, plist_t * plist_node)
if (!xmlStrcmp(node->name, XPLIST_KEY)) if (!xmlStrcmp(node->name, XPLIST_KEY))
{ {
xmlChar *strval = xmlNodeGetContent(node); xmlChar *strval = xmlNodeGetContent(node);
len = strlen((char *) strval);
type = xmlDetectCharEncoding(strval, len);
if (XML_CHAR_ENCODING_UTF8 == type || XML_CHAR_ENCODING_ASCII == type || XML_CHAR_ENCODING_NONE == type)
{
data->strval = strdup((char *) strval); data->strval = strdup((char *) strval);
data->type = PLIST_KEY; data->type = PLIST_KEY;
data->length = strlen(data->strval); data->length = strlen(data->strval);
}
xmlFree(strval); xmlFree(strval);
continue; continue;
} }
......
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