summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/xplist.c11
-rw-r--r--test/data/empty_keys.plist5
2 files changed, 16 insertions, 0 deletions
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 @@
<string>empty key</string>
<key><!-- comment --></key>
<string>empty key with comment</string>
+ <key>self-closing</key>
+ <dict>
+ <key/>
+ <string>self-closing empty key</string>
+ </dict>
</dict>
</plist>