summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/xplist.c111
1 files changed, 66 insertions, 45 deletions
diff --git a/src/xplist.c b/src/xplist.c
index 9dd43fe..1fc3fc1 100644
--- a/src/xplist.c
+++ b/src/xplist.c
@@ -47,17 +47,26 @@
47#include "strbuf.h" 47#include "strbuf.h"
48#include "time64.h" 48#include "time64.h"
49 49
50#define XPLIST_TEXT "text"
51#define XPLIST_KEY "key" 50#define XPLIST_KEY "key"
51#define XPLIST_KEY_LEN 3
52#define XPLIST_FALSE "false" 52#define XPLIST_FALSE "false"
53#define XPLIST_FALSE_LEN 5
53#define XPLIST_TRUE "true" 54#define XPLIST_TRUE "true"
55#define XPLIST_TRUE_LEN 4
54#define XPLIST_INT "integer" 56#define XPLIST_INT "integer"
57#define XPLIST_INT_LEN 7
55#define XPLIST_REAL "real" 58#define XPLIST_REAL "real"
59#define XPLIST_REAL_LEN 4
56#define XPLIST_DATE "date" 60#define XPLIST_DATE "date"
61#define XPLIST_DATE_LEN 4
57#define XPLIST_DATA "data" 62#define XPLIST_DATA "data"
63#define XPLIST_DATA_LEN 4
58#define XPLIST_STRING "string" 64#define XPLIST_STRING "string"
65#define XPLIST_STRING_LEN 6
59#define XPLIST_ARRAY "array" 66#define XPLIST_ARRAY "array"
67#define XPLIST_ARRAY_LEN 5
60#define XPLIST_DICT "dict" 68#define XPLIST_DICT "dict"
69#define XPLIST_DICT_LEN 4
61 70
62#define MAC_EPOCH 978307200 71#define MAC_EPOCH 978307200
63 72
@@ -89,7 +98,7 @@ void plist_xml_deinit(void)
89 /* deinit XML stuff */ 98 /* deinit XML stuff */
90} 99}
91 100
92static void dtostr(char *buf, size_t bufsize, double realval) 101static size_t dtostr(char *buf, size_t bufsize, double realval)
93{ 102{
94 double f = realval; 103 double f = realval;
95 double ip = 0.0; 104 double ip = 0.0;
@@ -100,7 +109,7 @@ static void dtostr(char *buf, size_t bufsize, double realval)
100 f = modf(f, &ip); 109 f = modf(f, &ip);
101 len = snprintf(buf, bufsize, "%s%"PRIi64, ((f < 0) && (ip >= 0)) ? "-" : "", (int64_t)ip); 110 len = snprintf(buf, bufsize, "%s%"PRIi64, ((f < 0) && (ip >= 0)) ? "-" : "", (int64_t)ip);
102 if (len >= bufsize) { 111 if (len >= bufsize) {
103 return; 112 return 0;
104 } 113 }
105 114
106 if (f < 0) { 115 if (f < 0) {
@@ -117,6 +126,7 @@ static void dtostr(char *buf, size_t bufsize, double realval)
117 buf[p++] = (v + 0x30); 126 buf[p++] = (v + 0x30);
118 } 127 }
119 buf[p] = '\0'; 128 buf[p] = '\0';
129 return p;
120} 130}
121 131
122static void node_to_xml(node_t* node, bytearray_t **outbuf, uint32_t depth) 132static void node_to_xml(node_t* node, bytearray_t **outbuf, uint32_t depth)
@@ -127,7 +137,9 @@ static void node_to_xml(node_t* node, bytearray_t **outbuf, uint32_t depth)
127 char tagOpen = FALSE; 137 char tagOpen = FALSE;
128 138
129 const char *tag = NULL; 139 const char *tag = NULL;
140 size_t tag_len = 0;
130 char *val = NULL; 141 char *val = NULL;
142 size_t val_len = 0;
131 143
132 uint32_t i = 0; 144 uint32_t i = 0;
133 145
@@ -140,53 +152,64 @@ static void node_to_xml(node_t* node, bytearray_t **outbuf, uint32_t depth)
140 { 152 {
141 case PLIST_BOOLEAN: 153 case PLIST_BOOLEAN:
142 { 154 {
143 if (node_data->boolval) 155 if (node_data->boolval) {
144 tag = XPLIST_TRUE; 156 tag = XPLIST_TRUE;
145 else 157 tag_len = XPLIST_TRUE_LEN;
158 } else {
146 tag = XPLIST_FALSE; 159 tag = XPLIST_FALSE;
160 tag_len = XPLIST_FALSE_LEN;
161 }
147 } 162 }
148 break; 163 break;
149 164
150 case PLIST_UINT: 165 case PLIST_UINT:
151 tag = XPLIST_INT; 166 tag = XPLIST_INT;
167 tag_len = XPLIST_INT_LEN;
152 val = (char*)malloc(64); 168 val = (char*)malloc(64);
153 if (node_data->length == 16) { 169 if (node_data->length == 16) {
154 (void)snprintf(val, 64, "%"PRIu64, node_data->intval); 170 val_len = snprintf(val, 64, "%"PRIu64, node_data->intval);
155 } else { 171 } else {
156 (void)snprintf(val, 64, "%"PRIi64, node_data->intval); 172 val_len = snprintf(val, 64, "%"PRIi64, node_data->intval);
157 } 173 }
158 break; 174 break;
159 175
160 case PLIST_REAL: 176 case PLIST_REAL:
161 tag = XPLIST_REAL; 177 tag = XPLIST_REAL;
178 tag_len = XPLIST_REAL_LEN;
162 val = (char*)malloc(64); 179 val = (char*)malloc(64);
163 dtostr(val, 64, node_data->realval); 180 val_len = dtostr(val, 64, node_data->realval);
164 break; 181 break;
165 182
166 case PLIST_STRING: 183 case PLIST_STRING:
167 tag = XPLIST_STRING; 184 tag = XPLIST_STRING;
185 tag_len = XPLIST_STRING_LEN;
168 /* contents processed directly below */ 186 /* contents processed directly below */
169 break; 187 break;
170 188
171 case PLIST_KEY: 189 case PLIST_KEY:
172 tag = XPLIST_KEY; 190 tag = XPLIST_KEY;
191 tag_len = XPLIST_KEY_LEN;
173 /* contents processed directly below */ 192 /* contents processed directly below */
174 break; 193 break;
175 194
176 case PLIST_DATA: 195 case PLIST_DATA:
177 tag = XPLIST_DATA; 196 tag = XPLIST_DATA;
197 tag_len = XPLIST_DATA_LEN;
178 /* contents processed directly below */ 198 /* contents processed directly below */
179 break; 199 break;
180 case PLIST_ARRAY: 200 case PLIST_ARRAY:
181 tag = XPLIST_ARRAY; 201 tag = XPLIST_ARRAY;
202 tag_len = XPLIST_ARRAY_LEN;
182 isStruct = TRUE; 203 isStruct = TRUE;
183 break; 204 break;
184 case PLIST_DICT: 205 case PLIST_DICT:
185 tag = XPLIST_DICT; 206 tag = XPLIST_DICT;
207 tag_len = XPLIST_DICT_LEN;
186 isStruct = TRUE; 208 isStruct = TRUE;
187 break; 209 break;
188 case PLIST_DATE: 210 case PLIST_DATE:
189 tag = XPLIST_DATE; 211 tag = XPLIST_DATE;
212 tag_len = XPLIST_DATE_LEN;
190 { 213 {
191 Time64_T timev = (Time64_T)node_data->realval + MAC_EPOCH; 214 Time64_T timev = (Time64_T)node_data->realval + MAC_EPOCH;
192 struct TM _btime; 215 struct TM _btime;
@@ -196,7 +219,8 @@ static void node_to_xml(node_t* node, bytearray_t **outbuf, uint32_t depth)
196 memset(val, 0, 24); 219 memset(val, 0, 24);
197 struct tm _tmcopy; 220 struct tm _tmcopy;
198 copy_TM64_to_tm(btime, &_tmcopy); 221 copy_TM64_to_tm(btime, &_tmcopy);
199 if (strftime(val, 24, "%Y-%m-%dT%H:%M:%SZ", &_tmcopy) <= 0) { 222 val_len = strftime(val, 24, "%Y-%m-%dT%H:%M:%SZ", &_tmcopy);
223 if (val_len <= 0) {
200 free (val); 224 free (val);
201 val = NULL; 225 val = NULL;
202 } 226 }
@@ -205,12 +229,13 @@ static void node_to_xml(node_t* node, bytearray_t **outbuf, uint32_t depth)
205 break; 229 break;
206 case PLIST_UID: 230 case PLIST_UID:
207 tag = XPLIST_DICT; 231 tag = XPLIST_DICT;
232 tag_len = XPLIST_DICT_LEN;
208 val = (char*)malloc(64); 233 val = (char*)malloc(64);
209 if (node_data->length == 16) { 234 if (node_data->length == 16) {
210 (void)snprintf(val, 64, "%"PRIu64, node_data->intval); 235 val_len = snprintf(val, 64, "%"PRIu64, node_data->intval);
211 } else { 236 } else {
212 (void)snprintf(val, 64, "%"PRIi64, node_data->intval); 237 val_len = snprintf(val, 64, "%"PRIi64, node_data->intval);
213 } 238 }
214 break; 239 break;
215 default: 240 default:
216 break; 241 break;
@@ -222,7 +247,7 @@ static void node_to_xml(node_t* node, bytearray_t **outbuf, uint32_t depth)
222 247
223 /* append tag */ 248 /* append tag */
224 str_buf_append(*outbuf, "<", 1); 249 str_buf_append(*outbuf, "<", 1);
225 str_buf_append(*outbuf, tag, strlen(tag)); 250 str_buf_append(*outbuf, tag, tag_len);
226 if (node_data->type == PLIST_STRING || node_data->type == PLIST_KEY) { 251 if (node_data->type == PLIST_STRING || node_data->type == PLIST_KEY) {
227 size_t j; 252 size_t j;
228 size_t len; 253 size_t len;
@@ -233,8 +258,8 @@ static void node_to_xml(node_t* node, bytearray_t **outbuf, uint32_t depth)
233 tagOpen = TRUE; 258 tagOpen = TRUE;
234 259
235 /* make sure we convert the following predefined xml entities */ 260 /* make sure we convert the following predefined xml entities */
236 /* < = &lt; > = &gt; ' = &apos; " = &quot; & = &amp; */ 261 /* < = &lt; > = &gt; & = &amp; */
237 len = strlen(node_data->strval); 262 len = node_data->length;
238 for (j = 0; j < len; j++) { 263 for (j = 0; j < len; j++) {
239 switch (node_data->strval[j]) { 264 switch (node_data->strval[j]) {
240 case '<': 265 case '<':
@@ -302,7 +327,7 @@ static void node_to_xml(node_t* node, bytearray_t **outbuf, uint32_t depth)
302 str_buf_append(*outbuf, "\t", 1); 327 str_buf_append(*outbuf, "\t", 1);
303 } 328 }
304 str_buf_append(*outbuf, "<integer>", 9); 329 str_buf_append(*outbuf, "<integer>", 9);
305 str_buf_append(*outbuf, val, strlen(val)); 330 str_buf_append(*outbuf, val, val_len);
306 str_buf_append(*outbuf, "</integer>", 10); 331 str_buf_append(*outbuf, "</integer>", 10);
307 str_buf_append(*outbuf, "\n", 1); 332 str_buf_append(*outbuf, "\n", 1);
308 333
@@ -312,7 +337,7 @@ static void node_to_xml(node_t* node, bytearray_t **outbuf, uint32_t depth)
312 } else if (val) { 337 } else if (val) {
313 str_buf_append(*outbuf, ">", 1); 338 str_buf_append(*outbuf, ">", 1);
314 tagOpen = TRUE; 339 tagOpen = TRUE;
315 str_buf_append(*outbuf, val, strlen(val)); 340 str_buf_append(*outbuf, val, val_len);
316 } else if (isStruct) { 341 } else if (isStruct) {
317 tagOpen = TRUE; 342 tagOpen = TRUE;
318 str_buf_append(*outbuf, ">", 1); 343 str_buf_append(*outbuf, ">", 1);
@@ -345,7 +370,7 @@ static void node_to_xml(node_t* node, bytearray_t **outbuf, uint32_t depth)
345 if (tagOpen) { 370 if (tagOpen) {
346 /* add closing tag */ 371 /* add closing tag */
347 str_buf_append(*outbuf, "</", 2); 372 str_buf_append(*outbuf, "</", 2);
348 str_buf_append(*outbuf, tag, strlen(tag)); 373 str_buf_append(*outbuf, tag, tag_len);
349 str_buf_append(*outbuf, ">", 1); 374 str_buf_append(*outbuf, ">", 1);
350 } 375 }
351 str_buf_append(*outbuf, "\n", 1); 376 str_buf_append(*outbuf, "\n", 1);
@@ -419,9 +444,8 @@ static void find_char(parse_ctx ctx, char c, int skip_quotes)
419 } 444 }
420} 445}
421 446
422static void find_str(parse_ctx ctx, const char *str, int skip_quotes) 447static void find_str(parse_ctx ctx, const char *str, size_t len, int skip_quotes)
423{ 448{
424 size_t len = strlen(str);
425 while (ctx->pos < (ctx->end - len)) { 449 while (ctx->pos < (ctx->end - len)) {
426 if (!strncmp(ctx->pos, str, len)) { 450 if (!strncmp(ctx->pos, str, len)) {
427 break; 451 break;
@@ -438,9 +462,8 @@ static void find_str(parse_ctx ctx, const char *str, int skip_quotes)
438 } 462 }
439} 463}
440 464
441static void find_next(parse_ctx ctx, const char *nextchars, int skip_quotes) 465static void find_next(parse_ctx ctx, const char *nextchars, int numchars, int skip_quotes)
442{ 466{
443 int numchars = strlen(nextchars);
444 int i = 0; 467 int i = 0;
445 while (ctx->pos < ctx->end) { 468 while (ctx->pos < ctx->end) {
446 if (skip_quotes && (*(ctx->pos) == '"')) { 469 if (skip_quotes && (*(ctx->pos) == '"')) {
@@ -493,11 +516,10 @@ static text_part_t* text_part_append(text_part_t* parts, const char *begin, size
493 return newpart; 516 return newpart;
494} 517}
495 518
496static text_part_t* get_text_parts(parse_ctx ctx, const char* tag, int skip_ws, text_part_t *parts) 519static text_part_t* get_text_parts(parse_ctx ctx, const char* tag, size_t tag_len, int skip_ws, text_part_t *parts)
497{ 520{
498 const char *p = NULL; 521 const char *p = NULL;
499 const char *q = NULL; 522 const char *q = NULL;
500 int taglen = 0;
501 text_part_t *last = NULL; 523 text_part_t *last = NULL;
502 524
503 if (skip_ws) { 525 if (skip_ws) {
@@ -527,7 +549,7 @@ static text_part_t* get_text_parts(parse_ctx ctx, const char* tag, int skip_ws,
527 last = text_part_init(parts, p, q-p, 0); 549 last = text_part_init(parts, p, q-p, 0);
528 } 550 }
529 ctx->pos += 2; 551 ctx->pos += 2;
530 find_str(ctx, "-->", 0); 552 find_str(ctx, "-->", 3, 0);
531 if (ctx->pos >= ctx->end || strncmp(ctx->pos, "-->", 3) != 0) { 553 if (ctx->pos >= ctx->end || strncmp(ctx->pos, "-->", 3) != 0) {
532 PLIST_XML_ERR("EOF while looking for end of comment\n"); 554 PLIST_XML_ERR("EOF while looking for end of comment\n");
533 ctx->err++; 555 ctx->err++;
@@ -551,7 +573,7 @@ static text_part_t* get_text_parts(parse_ctx ctx, const char* tag, int skip_ws,
551 } 573 }
552 ctx->pos+=6; 574 ctx->pos+=6;
553 p = ctx->pos; 575 p = ctx->pos;
554 find_str(ctx, "]]>", 0); 576 find_str(ctx, "]]>", 3, 0);
555 if (ctx->pos >= ctx->end || strncmp(ctx->pos, "]]>", 3) != 0) { 577 if (ctx->pos >= ctx->end || strncmp(ctx->pos, "]]>", 3) != 0) {
556 PLIST_XML_ERR("EOF while looking for end of CDATA block\n"); 578 PLIST_XML_ERR("EOF while looking for end of CDATA block\n");
557 ctx->err++; 579 ctx->err++;
@@ -579,13 +601,12 @@ static text_part_t* get_text_parts(parse_ctx ctx, const char* tag, int skip_ws,
579 } 601 }
580 } while (1); 602 } while (1);
581 ctx->pos++; 603 ctx->pos++;
582 taglen = strlen(tag); 604 if (ctx->pos >= ctx->end-tag_len || strncmp(ctx->pos, tag, tag_len)) {
583 if (ctx->pos >= ctx->end-taglen || strncmp(ctx->pos, tag, taglen)) {
584 PLIST_XML_ERR("EOF or end tag mismatch\n"); 605 PLIST_XML_ERR("EOF or end tag mismatch\n");
585 ctx->err++; 606 ctx->err++;
586 return NULL; 607 return NULL;
587 } 608 }
588 ctx->pos+=taglen; 609 ctx->pos+=tag_len;
589 if (ctx->pos >= ctx->end || *ctx->pos != '>') { 610 if (ctx->pos >= ctx->end || *ctx->pos != '>') {
590 PLIST_XML_ERR("EOF or no '>' after tag name\n"); 611 PLIST_XML_ERR("EOF or no '>' after tag name\n");
591 ctx->err++; 612 ctx->err++;
@@ -760,7 +781,7 @@ static void node_from_xml(parse_ctx ctx, plist_t *plist)
760 } 781 }
761 782
762 if (*(ctx->pos) == '?') { 783 if (*(ctx->pos) == '?') {
763 find_str(ctx, "?>", 1); 784 find_str(ctx, "?>", 2, 1);
764 if (ctx->pos >= ctx->end) { 785 if (ctx->pos >= ctx->end) {
765 break; 786 break;
766 } 787 }
@@ -775,7 +796,7 @@ static void node_from_xml(parse_ctx ctx, plist_t *plist)
775 /* comment or DTD */ 796 /* comment or DTD */
776 if (((ctx->end - ctx->pos) > 3) && !strncmp(ctx->pos, "!--", 3)) { 797 if (((ctx->end - ctx->pos) > 3) && !strncmp(ctx->pos, "!--", 3)) {
777 ctx->pos += 3; 798 ctx->pos += 3;
778 find_str(ctx,"-->", 0); 799 find_str(ctx,"-->", 3, 0);
779 if (strncmp(ctx->pos, "-->", 3)) { 800 if (strncmp(ctx->pos, "-->", 3)) {
780 PLIST_XML_ERR("Couldn't find end of comment\n"); 801 PLIST_XML_ERR("Couldn't find end of comment\n");
781 ctx->pos = ctx->end; 802 ctx->pos = ctx->end;
@@ -786,7 +807,7 @@ static void node_from_xml(parse_ctx ctx, plist_t *plist)
786 int embedded_dtd = 0; 807 int embedded_dtd = 0;
787 ctx->pos+=8; 808 ctx->pos+=8;
788 while (ctx->pos < ctx->end) { 809 while (ctx->pos < ctx->end) {
789 find_next(ctx, " \t\r\n[>", 1); 810 find_next(ctx, " \t\r\n[>", 6, 1);
790 if (*ctx->pos == '[') { 811 if (*ctx->pos == '[') {
791 embedded_dtd = 1; 812 embedded_dtd = 1;
792 break; 813 break;
@@ -799,7 +820,7 @@ static void node_from_xml(parse_ctx ctx, plist_t *plist)
799 } 820 }
800 } 821 }
801 if (embedded_dtd) { 822 if (embedded_dtd) {
802 find_str(ctx, "]>", 1); 823 find_str(ctx, "]>", 2, 1);
803 if (strncmp(ctx->pos, "]>", 2)) { 824 if (strncmp(ctx->pos, "]>", 2)) {
804 PLIST_XML_ERR("Couldn't find end of DOCTYPE\n"); 825 PLIST_XML_ERR("Couldn't find end of DOCTYPE\n");
805 ctx->pos = ctx->end; 826 ctx->pos = ctx->end;
@@ -816,7 +837,7 @@ static void node_from_xml(parse_ctx ctx, plist_t *plist)
816 int is_empty = 0; 837 int is_empty = 0;
817 int closing_tag = 0; 838 int closing_tag = 0;
818 const char *p = ctx->pos; 839 const char *p = ctx->pos;
819 find_next(ctx," \r\n\t<>",0); 840 find_next(ctx," \r\n\t<>", 6, 0);
820 if (ctx->pos >= ctx->end) { 841 if (ctx->pos >= ctx->end) {
821 PLIST_XML_ERR("Unexpected EOF while parsing XML\n"); 842 PLIST_XML_ERR("Unexpected EOF while parsing XML\n");
822 ctx->pos = ctx->end; 843 ctx->pos = ctx->end;
@@ -829,7 +850,7 @@ static void node_from_xml(parse_ctx ctx, plist_t *plist)
829 strncpy(tag, p, taglen); 850 strncpy(tag, p, taglen);
830 tag[taglen] = '\0'; 851 tag[taglen] = '\0';
831 if (*ctx->pos != '>') { 852 if (*ctx->pos != '>') {
832 find_next(ctx, "<>", 1); 853 find_next(ctx, "<>", 2, 1);
833 } 854 }
834 if (ctx->pos >= ctx->end) { 855 if (ctx->pos >= ctx->end) {
835 PLIST_XML_ERR("Unexpected EOF while parsing XML\n"); 856 PLIST_XML_ERR("Unexpected EOF while parsing XML\n");
@@ -876,7 +897,7 @@ static void node_from_xml(parse_ctx ctx, plist_t *plist)
876 } else if (!strcmp(tag, XPLIST_INT)) { 897 } else if (!strcmp(tag, XPLIST_INT)) {
877 if (!is_empty) { 898 if (!is_empty) {
878 text_part_t first_part = { NULL, 0, 0, NULL }; 899 text_part_t first_part = { NULL, 0, 0, NULL };
879 text_part_t *tp = get_text_parts(ctx, tag, 1, &first_part); 900 text_part_t *tp = get_text_parts(ctx, tag, taglen, 1, &first_part);
880 if (!tp) { 901 if (!tp) {
881 PLIST_XML_ERR("Could not parse text content for '%s' node\n", tag); 902 PLIST_XML_ERR("Could not parse text content for '%s' node\n", tag);
882 text_parts_free(first_part.next); 903 text_parts_free(first_part.next);
@@ -930,7 +951,7 @@ static void node_from_xml(parse_ctx ctx, plist_t *plist)
930 } else if (!strcmp(tag, XPLIST_REAL)) { 951 } else if (!strcmp(tag, XPLIST_REAL)) {
931 if (!is_empty) { 952 if (!is_empty) {
932 text_part_t first_part = { NULL, 0, 0, NULL }; 953 text_part_t first_part = { NULL, 0, 0, NULL };
933 text_part_t *tp = get_text_parts(ctx, tag, 1, &first_part); 954 text_part_t *tp = get_text_parts(ctx, tag, taglen, 1, &first_part);
934 if (!tp) { 955 if (!tp) {
935 PLIST_XML_ERR("Could not parse text content for '%s' node\n", tag); 956 PLIST_XML_ERR("Could not parse text content for '%s' node\n", tag);
936 text_parts_free(first_part.next); 957 text_parts_free(first_part.next);
@@ -960,14 +981,14 @@ static void node_from_xml(parse_ctx ctx, plist_t *plist)
960 data->length = 8; 981 data->length = 8;
961 } else if (!strcmp(tag, XPLIST_TRUE)) { 982 } else if (!strcmp(tag, XPLIST_TRUE)) {
962 if (!is_empty) { 983 if (!is_empty) {
963 get_text_parts(ctx, tag, 1, NULL); 984 get_text_parts(ctx, tag, taglen, 1, NULL);
964 } 985 }
965 data->type = PLIST_BOOLEAN; 986 data->type = PLIST_BOOLEAN;
966 data->boolval = 1; 987 data->boolval = 1;
967 data->length = 1; 988 data->length = 1;
968 } else if (!strcmp(tag, XPLIST_FALSE)) { 989 } else if (!strcmp(tag, XPLIST_FALSE)) {
969 if (!is_empty) { 990 if (!is_empty) {
970 get_text_parts(ctx, tag, 1, NULL); 991 get_text_parts(ctx, tag, taglen, 1, NULL);
971 } 992 }
972 data->type = PLIST_BOOLEAN; 993 data->type = PLIST_BOOLEAN;
973 data->boolval = 0; 994 data->boolval = 0;
@@ -975,7 +996,7 @@ static void node_from_xml(parse_ctx ctx, plist_t *plist)
975 } else if (!strcmp(tag, XPLIST_STRING) || !strcmp(tag, XPLIST_KEY)) { 996 } else if (!strcmp(tag, XPLIST_STRING) || !strcmp(tag, XPLIST_KEY)) {
976 if (!is_empty) { 997 if (!is_empty) {
977 text_part_t first_part = { NULL, 0, 0, NULL }; 998 text_part_t first_part = { NULL, 0, 0, NULL };
978 text_part_t *tp = get_text_parts(ctx, tag, 0, &first_part); 999 text_part_t *tp = get_text_parts(ctx, tag, taglen, 0, &first_part);
979 char *str = NULL; 1000 char *str = NULL;
980 size_t length = 0; 1001 size_t length = 0;
981 if (!tp) { 1002 if (!tp) {
@@ -1012,7 +1033,7 @@ static void node_from_xml(parse_ctx ctx, plist_t *plist)
1012 } else if (!strcmp(tag, XPLIST_DATA)) { 1033 } else if (!strcmp(tag, XPLIST_DATA)) {
1013 if (!is_empty) { 1034 if (!is_empty) {
1014 text_part_t first_part = { NULL, 0, 0, NULL }; 1035 text_part_t first_part = { NULL, 0, 0, NULL };
1015 text_part_t *tp = get_text_parts(ctx, tag, 1, &first_part); 1036 text_part_t *tp = get_text_parts(ctx, tag, taglen, 1, &first_part);
1016 if (!tp) { 1037 if (!tp) {
1017 PLIST_XML_ERR("Could not parse text content for '%s' node\n", tag); 1038 PLIST_XML_ERR("Could not parse text content for '%s' node\n", tag);
1018 text_parts_free(first_part.next); 1039 text_parts_free(first_part.next);
@@ -1045,7 +1066,7 @@ static void node_from_xml(parse_ctx ctx, plist_t *plist)
1045 } else if (!strcmp(tag, XPLIST_DATE)) { 1066 } else if (!strcmp(tag, XPLIST_DATE)) {
1046 if (!is_empty) { 1067 if (!is_empty) {
1047 text_part_t first_part = { NULL, 0, 0, NULL }; 1068 text_part_t first_part = { NULL, 0, 0, NULL };
1048 text_part_t *tp = get_text_parts(ctx, tag, 1, &first_part); 1069 text_part_t *tp = get_text_parts(ctx, tag, taglen, 1, &first_part);
1049 if (!tp) { 1070 if (!tp) {
1050 PLIST_XML_ERR("Could not parse text content for '%s' node\n", tag); 1071 PLIST_XML_ERR("Could not parse text content for '%s' node\n", tag);
1051 text_parts_free(first_part.next); 1072 text_parts_free(first_part.next);