From e07823056859ee644cfe1dff93f80691d10c656e Mon Sep 17 00:00:00 2001 From: Dave Nicolson Date: Sat, 21 Nov 2026 22:57:50 +0100 Subject: [PATCH] Keep non-integer CF$UID dictionaries --- src/xplist.c | 7 +------ test/xml_behavior_test.c | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 6 deletions(-) diff --git a/src/xplist.c b/src/xplist.c index 92ca15d9f..afeddaf06 100644 --- a/src/xplist.c +++ b/src/xplist.c @@ -1604,13 +1604,8 @@ static plist_err_t node_from_xml(parse_ctx ctx, plist_t *plist) if (!strcmp(node_path->type, XPLIST_DICT) && parent && plist_get_node_type(parent) == PLIST_DICT) { if (plist_dict_get_size(parent) == 1) { plist_t uid = plist_dict_get_item(parent, "CF$UID"); - if (uid) { + if (uid && plist_get_node_type(uid) == PLIST_INT) { uint64_t val = 0; - if (plist_get_node_type(uid) != PLIST_INT) { - ctx->err = PLIST_ERR_PARSE; - PLIST_XML_ERR("Invalid node type for CF$UID dict entry (must be PLIST_INT)\n"); - goto err_out; - } plist_get_uint_val(uid, &val); plist_set_uid_val(parent, val); } diff --git a/test/xml_behavior_test.c b/test/xml_behavior_test.c index 94d8a7f5e..714bd0bdc 100644 --- a/test/xml_behavior_test.c +++ b/test/xml_behavior_test.c @@ -154,6 +154,40 @@ static int test_scalar_with_comment_is_ok(void) return 1; } +static int test_cfuid_boolean_stays_dictionary(void) +{ + const char *xml = + "" + "" + " " + " CF$UID" + " " + " " + ""; + plist_t root = NULL; + plist_t value = NULL; + plist_err_t err = plist_from_xml(xml, (uint32_t)strlen(xml), &root); + + if (err != PLIST_ERR_SUCCESS || !root) { + fprintf(stderr, "CF$UID boolean: plist_from_xml failed (err=%d)\n", err); + plist_free(root); + return 0; + } + if (plist_get_node_type(root) != PLIST_DICT) { + fprintf(stderr, "CF$UID boolean: expected dict node\n"); + plist_free(root); + return 0; + } + value = plist_dict_get_item(root, "CF$UID"); + if (!value || plist_get_node_type(value) != PLIST_BOOLEAN) { + fprintf(stderr, "CF$UID boolean: expected boolean value\n"); + plist_free(root); + return 0; + } + plist_free(root); + return 1; +} + int main(void) { int ok = 1; @@ -162,6 +196,7 @@ int main(void) ok &= test_extra_root_value_is_rejected(); ok &= test_scalar_then_extra_node_is_rejected(); ok &= test_scalar_with_comment_is_ok(); + ok &= test_cfuid_boolean_stays_dictionary(); return ok ? 0 : 1; }