summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Nikias Bassen2021-12-23 02:05:42 +0100
committerGravatar Nikias Bassen2021-12-23 02:05:42 +0100
commit7aaa371944544bbbfade3c8e17846f8f58711869 (patch)
treee5a8e8e08a0e24dc49b2ba4b3c08e7843ba9ff8c
parent70f4a422e01910cdb783aac81f13c11223c3acbd (diff)
downloadlibplist-7aaa371944544bbbfade3c8e17846f8f58711869.tar.gz
libplist-7aaa371944544bbbfade3c8e17846f8f58711869.tar.bz2
xplist: Add special handling for PLIST_UID parsing from XML
In XML, PLIST_UID nodes are stored as a dict with a "CF$UID" key and an integer value, so we want to make it a real PLIST_UID node internally.
-rw-r--r--src/xplist.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/src/xplist.c b/src/xplist.c
index 3971622..9569d07 100644
--- a/src/xplist.c
+++ b/src/xplist.c
@@ -955,7 +955,6 @@ static char* text_parts_get_content(text_part_t *tp, int unesc_entities, size_t
static int node_from_xml(parse_ctx ctx, plist_t *plist)
{
- int res;
char *tag = NULL;
char *keyname = NULL;
plist_t subnode = NULL;
@@ -1449,11 +1448,21 @@ err_out:
if (ctx->err) {
plist_free(*plist);
*plist = NULL;
- res = PLIST_ERR_PARSE;
- } else {
- res = PLIST_ERR_SUCCESS;
+ return PLIST_ERR_PARSE;
}
- return res;
+
+ /* check if we have a UID "dict" so we can replace it with a proper UID node */
+ if (PLIST_IS_DICT(*plist) && plist_dict_get_size(*plist) == 1) {
+ plist_t value = plist_dict_get_item(*plist, "CF$UID");
+ if (PLIST_IS_UINT(value)) {
+ uint64_t u64val = 0;
+ plist_get_uint_val(value, &u64val);
+ plist_free(*plist);
+ *plist = plist_new_uid(u64val);
+ }
+ }
+
+ return PLIST_ERR_SUCCESS;
}
PLIST_API plist_err_t plist_from_xml(const char *plist_xml, uint32_t length, plist_t * plist)