Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions src/xplist.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
35 changes: 35 additions & 0 deletions test/xml_behavior_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
"<plist version=\"1.0\">"
" <dict>"
" <key>CF$UID</key>"
" <true/>"
" </dict>"
"</plist>";
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;
Expand All @@ -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;
}
Loading