summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGravatar Nikias Bassen2025-11-14 20:07:02 +0100
committerGravatar Nikias Bassen2025-11-14 20:11:43 +0100
commit2c50f76481429c495628c56223b7810c5af0b2cd (patch)
tree203ab1a65f8e1f9631c53fa2983d71d760c209cc /src
parent438f01bad1437a15d35fa102bcde693171f03074 (diff)
downloadlibplist-2c50f76481429c495628c56223b7810c5af0b2cd.tar.gz
libplist-2c50f76481429c495628c56223b7810c5af0b2cd.tar.bz2
xplist: Allow empty key entry in PLIST_DICTHEADmaster
Even though this is weird, the DTD allows it. This commit will also make the XML output write `<key/>` and `<string/>` instead of `<key></key>` and `<string></string>` in case of empty key/string node.
Diffstat (limited to 'src')
-rw-r--r--src/xplist.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/xplist.c b/src/xplist.c
index 7e39ea4..dc5213b 100644
--- a/src/xplist.c
+++ b/src/xplist.c
@@ -256,7 +256,7 @@ static plist_err_t node_to_xml(node_t node, bytearray_t **outbuf, uint32_t depth
/* append tag */
str_buf_append(*outbuf, "<", 1);
str_buf_append(*outbuf, tag, tag_len);
- if (node_data->type == PLIST_STRING || node_data->type == PLIST_KEY) {
+ if ((node_data->type == PLIST_STRING || node_data->type == PLIST_KEY) && node_data->length > 0) {
size_t j;
size_t len;
off_t start = 0;
@@ -1274,6 +1274,14 @@ static plist_err_t node_from_xml(parse_ctx ctx, plist_t *plist)
data->length = length;
}
} else {
+ if (!strcmp(tag, "key") && !keyname && parent && (plist_get_node_type(parent) == PLIST_DICT)) {
+ keyname = strdup("");
+ free(tag);
+ tag = NULL;
+ plist_free(subnode);
+ subnode = NULL;
+ continue;
+ }
data->strval = strdup("");
data->length = 0;
}