From 2c50f76481429c495628c56223b7810c5af0b2cd Mon Sep 17 00:00:00 2001 From: Nikias Bassen Date: Fri, 14 Nov 2025 20:07:02 +0100 Subject: xplist: Allow empty key entry in PLIST_DICT Even though this is weird, the DTD allows it. This commit will also make the XML output write `` and `` instead of `` and `` in case of empty key/string node. --- src/xplist.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) 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; } -- cgit v1.1-32-gdbae