diff options
| -rw-r--r-- | src/xplist.c | 16 |
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 | /* < = < > = > ' = ' " = " & = & */ | 262 | /* < = < > = > ' = ' " = " & = & */ |
| 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 | } |
