From 3cfe22475244cc1e924b6fd189234c130d6c5914 Mon Sep 17 00:00:00 2001
From: Nikias Bassen
Date: Sat, 7 Nov 2026 12:29:06 +0100
Subject: xplist: accept a self-closing as an empty key
---
src/xplist.c | 11 +++++++++++
test/data/empty_keys.plist | 5 +++++
2 files changed, 16 insertions(+)
diff --git a/src/xplist.c b/src/xplist.c
index adf3f40..92ca15d 100644
--- a/src/xplist.c
+++ b/src/xplist.c
@@ -1405,6 +1405,17 @@ static plist_err_t node_from_xml(parse_ctx ctx, plist_t *plist)
data->length = length;
}
} else {
+ if (!strcmp(tag, XPLIST_KEY) && !keyname && parent && (plist_get_node_type(parent) == PLIST_DICT)) {
+ keyname = strdup("");
+ if (!keyname) {
+ PLIST_XML_ERR("failed to allocate key name\n");
+ ctx->err = PLIST_ERR_NO_MEM;
+ goto err_out;
+ }
+ plist_free(subnode);
+ subnode = NULL;
+ continue;
+ }
data->strval = strdup("");
data->length = 0;
}
diff --git a/test/data/empty_keys.plist b/test/data/empty_keys.plist
index a0107b4..bbc8ee4 100644
--- a/test/data/empty_keys.plist
+++ b/test/data/empty_keys.plist
@@ -4,5 +4,10 @@
empty key
empty key with comment
+ self-closing
+
+
+ self-closing empty key
+
--
cgit v1.1-32-gdbae