diff options
| -rw-r--r-- | src/xplist.c | 33 |
1 files changed, 18 insertions, 15 deletions
diff --git a/src/xplist.c b/src/xplist.c index ff065a9..98d7375 100644 --- a/src/xplist.c +++ b/src/xplist.c | |||
| @@ -589,14 +589,14 @@ static text_part_t* get_text_parts(parse_ctx ctx, const char* tag, size_t tag_le | |||
| 589 | } else { | 589 | } else { |
| 590 | p = ctx->pos; | 590 | p = ctx->pos; |
| 591 | find_next(ctx, " \r\n\t>", 5, 1); | 591 | find_next(ctx, " \r\n\t>", 5, 1); |
| 592 | PLIST_XML_ERR("Invalid special tag '<[%.*s>' encountered inside '<%s>' tag\n", (int)(ctx->pos - p), p, tag); | 592 | PLIST_XML_ERR("Invalid special tag <[%.*s> encountered inside <%s> tag\n", (int)(ctx->pos - p), p, tag); |
| 593 | ctx->err++; | 593 | ctx->err++; |
| 594 | return NULL; | 594 | return NULL; |
| 595 | } | 595 | } |
| 596 | } else { | 596 | } else { |
| 597 | p = ctx->pos; | 597 | p = ctx->pos; |
| 598 | find_next(ctx, " \r\n\t>", 5, 1); | 598 | find_next(ctx, " \r\n\t>", 5, 1); |
| 599 | PLIST_XML_ERR("Invalid special tag '<!%.*s>' encountered inside '<%s>' tag\n", (int)(ctx->pos - p), p, tag); | 599 | PLIST_XML_ERR("Invalid special tag <!%.*s> encountered inside <%s> tag\n", (int)(ctx->pos - p), p, tag); |
| 600 | ctx->err++; | 600 | ctx->err++; |
| 601 | return NULL; | 601 | return NULL; |
| 602 | } | 602 | } |
| @@ -605,7 +605,7 @@ static text_part_t* get_text_parts(parse_ctx ctx, const char* tag, size_t tag_le | |||
| 605 | } else { | 605 | } else { |
| 606 | p = ctx->pos; | 606 | p = ctx->pos; |
| 607 | find_next(ctx, " \r\n\t>", 5, 1); | 607 | find_next(ctx, " \r\n\t>", 5, 1); |
| 608 | PLIST_XML_ERR("Invalid tag '<%.*s>' encountered inside '<%s>' tag\n", (int)(ctx->pos - p), p, tag); | 608 | PLIST_XML_ERR("Invalid tag <%.*s> encountered inside <%s> tag\n", (int)(ctx->pos - p), p, tag); |
| 609 | ctx->err++; | 609 | ctx->err++; |
| 610 | return NULL; | 610 | return NULL; |
| 611 | } | 611 | } |
| @@ -788,16 +788,16 @@ static char* text_parts_get_content(text_part_t *tp, int unesc_entities, size_t | |||
| 788 | static void node_from_xml(parse_ctx ctx, plist_t *plist, uint32_t depth) | 788 | static void node_from_xml(parse_ctx ctx, plist_t *plist, uint32_t depth) |
| 789 | { | 789 | { |
| 790 | char *keyname = NULL; | 790 | char *keyname = NULL; |
| 791 | const char *p = NULL; | ||
| 791 | while (ctx->pos < ctx->end && !ctx->err) { | 792 | while (ctx->pos < ctx->end && !ctx->err) { |
| 792 | #ifdef DEBUG | ||
| 793 | const char *start = ctx->pos; | ||
| 794 | #endif | ||
| 795 | parse_skip_ws(ctx); | 793 | parse_skip_ws(ctx); |
| 796 | if (ctx->pos >= ctx->end) { | 794 | if (ctx->pos >= ctx->end) { |
| 797 | break; | 795 | break; |
| 798 | } | 796 | } |
| 799 | if (*ctx->pos != '<') { | 797 | if (*ctx->pos != '<') { |
| 800 | PLIST_XML_ERR("Failed to parse XML. Expected: opening tag, found: '%s', pos: %s\n", start, ctx->pos); | 798 | p = ctx->pos; |
| 799 | find_next(ctx, " \t\r\n", 4, 0); | ||
| 800 | PLIST_XML_ERR("Expected: opening tag, found: %.*s\n", (int)(ctx->pos - p), p); | ||
| 801 | ctx->pos = ctx->end; | 801 | ctx->pos = ctx->end; |
| 802 | ctx->err++; | 802 | ctx->err++; |
| 803 | break; | 803 | break; |
| @@ -856,14 +856,16 @@ static void node_from_xml(parse_ctx ctx, plist_t *plist, uint32_t depth) | |||
| 856 | ctx->pos += 2; | 856 | ctx->pos += 2; |
| 857 | } | 857 | } |
| 858 | } else { | 858 | } else { |
| 859 | PLIST_XML_ERR("Unknown ! special tag encountered\n"); | 859 | p = ctx->pos; |
| 860 | find_next(ctx, " \r\n\t>", 5, 1); | ||
| 861 | PLIST_XML_ERR("Invalid special tag <%.*s> encountered\n", (int)(ctx->pos - p), p); | ||
| 860 | ctx->err++; | 862 | ctx->err++; |
| 861 | } | 863 | } |
| 862 | continue; | 864 | continue; |
| 863 | } else { | 865 | } else { |
| 864 | int is_empty = 0; | 866 | int is_empty = 0; |
| 865 | int closing_tag = 0; | 867 | int closing_tag = 0; |
| 866 | const char *p = ctx->pos; | 868 | p = ctx->pos; |
| 867 | find_next(ctx," \r\n\t<>", 6, 0); | 869 | find_next(ctx," \r\n\t<>", 6, 0); |
| 868 | if (ctx->pos >= ctx->end) { | 870 | if (ctx->pos >= ctx->end) { |
| 869 | PLIST_XML_ERR("Unexpected EOF while parsing XML\n"); | 871 | PLIST_XML_ERR("Unexpected EOF while parsing XML\n"); |
| @@ -888,7 +890,7 @@ static void node_from_xml(parse_ctx ctx, plist_t *plist, uint32_t depth) | |||
| 888 | return; | 890 | return; |
| 889 | } | 891 | } |
| 890 | if (*ctx->pos != '>') { | 892 | if (*ctx->pos != '>') { |
| 891 | PLIST_XML_ERR("Missing '>' for tag '%s'\n", tag); | 893 | PLIST_XML_ERR("Missing '>' for tag <%s\n", tag); |
| 892 | ctx->pos = ctx->end; | 894 | ctx->pos = ctx->end; |
| 893 | ctx->err++; | 895 | ctx->err++; |
| 894 | free(tag); | 896 | free(tag); |
| @@ -905,6 +907,7 @@ static void node_from_xml(parse_ctx ctx, plist_t *plist, uint32_t depth) | |||
| 905 | if (!strcmp(tag, "plist")) { | 907 | if (!strcmp(tag, "plist")) { |
| 906 | free(tag); | 908 | free(tag); |
| 907 | if (is_empty) { | 909 | if (is_empty) { |
| 910 | PLIST_XML_ERR("Empty plist tag\n"); | ||
| 908 | return; | 911 | return; |
| 909 | } | 912 | } |
| 910 | if (!*plist) { | 913 | if (!*plist) { |
| @@ -920,7 +923,7 @@ static void node_from_xml(parse_ctx ctx, plist_t *plist, uint32_t depth) | |||
| 920 | free(keyname); | 923 | free(keyname); |
| 921 | return; | 924 | return; |
| 922 | } else if (depth == 1 && *plist) { | 925 | } else if (depth == 1 && *plist) { |
| 923 | PLIST_XML_ERR("Unexpected tag %s found while /plist is expected\n", tag); | 926 | PLIST_XML_ERR("Unexpected tag <%s> found while </plist> is expected\n", tag); |
| 924 | ctx->err++; | 927 | ctx->err++; |
| 925 | free(tag); | 928 | free(tag); |
| 926 | free(keyname); | 929 | free(keyname); |
| @@ -1151,7 +1154,7 @@ static void node_from_xml(parse_ctx ctx, plist_t *plist, uint32_t depth) | |||
| 1151 | } else if (tag[0] == '/') { | 1154 | } else if (tag[0] == '/') { |
| 1152 | closing_tag = 1; | 1155 | closing_tag = 1; |
| 1153 | } else { | 1156 | } else { |
| 1154 | PLIST_XML_ERR("Unexpected tag '<%s%s>' encountered while parsing XML\n", tag, (is_empty) ? "/" : ""); | 1157 | PLIST_XML_ERR("Unexpected tag <%s%s> encountered\n", tag, (is_empty) ? "/" : ""); |
| 1155 | ctx->pos = ctx->end; | 1158 | ctx->pos = ctx->end; |
| 1156 | ctx->err++; | 1159 | ctx->err++; |
| 1157 | free(tag); | 1160 | free(tag); |
| @@ -1219,13 +1222,13 @@ static void node_from_xml(parse_ctx ctx, plist_t *plist, uint32_t depth) | |||
| 1219 | PLIST_XML_ERR("missing value node in dict\n"); | 1222 | PLIST_XML_ERR("missing value node in dict\n"); |
| 1220 | ctx->err++; | 1223 | ctx->err++; |
| 1221 | } else if (strcmp(tag+1, XPLIST_DICT) != 0) { | 1224 | } else if (strcmp(tag+1, XPLIST_DICT) != 0) { |
| 1222 | PLIST_XML_ERR("closing tag mismatch, expected: /%s found: %s\n", XPLIST_DICT, tag); | 1225 | PLIST_XML_ERR("closing tag mismatch, expected: </%s> found: <%s>\n", XPLIST_DICT, tag); |
| 1223 | ctx->err++; | 1226 | ctx->err++; |
| 1224 | } | 1227 | } |
| 1225 | break; | 1228 | break; |
| 1226 | case PLIST_ARRAY: | 1229 | case PLIST_ARRAY: |
| 1227 | if (strcmp(tag+1, XPLIST_ARRAY) != 0) { | 1230 | if (strcmp(tag+1, XPLIST_ARRAY) != 0) { |
| 1228 | PLIST_XML_ERR("closing tag mismatch, expected: /%s found: %s\n", XPLIST_ARRAY, tag); | 1231 | PLIST_XML_ERR("closing tag mismatch, expected: </%s> found: <%s>\n", XPLIST_ARRAY, tag); |
| 1229 | ctx->err++; | 1232 | ctx->err++; |
| 1230 | } | 1233 | } |
| 1231 | break; | 1234 | break; |
| @@ -1246,7 +1249,7 @@ static void node_from_xml(parse_ctx ctx, plist_t *plist, uint32_t depth) | |||
| 1246 | } | 1249 | } |
| 1247 | } | 1250 | } |
| 1248 | if (depth == 1) { | 1251 | if (depth == 1) { |
| 1249 | PLIST_XML_ERR("EOF while /plist tag is expected\n"); | 1252 | PLIST_XML_ERR("EOF while </plist> tag is expected\n"); |
| 1250 | ctx->err++; | 1253 | ctx->err++; |
| 1251 | } | 1254 | } |
| 1252 | if (ctx->err) { | 1255 | if (ctx->err) { |
