summaryrefslogtreecommitdiffstats
path: root/src/xplist.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/xplist.c')
-rw-r--r--src/xplist.c33
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
} else {
p = ctx->pos;
find_next(ctx, " \r\n\t>", 5, 1);
- PLIST_XML_ERR("Invalid special tag '<[%.*s>' encountered inside '<%s>' tag\n", (int)(ctx->pos - p), p, tag);
+ PLIST_XML_ERR("Invalid special tag <[%.*s> encountered inside <%s> tag\n", (int)(ctx->pos - p), p, tag);
ctx->err++;
return NULL;
}
} else {
p = ctx->pos;
find_next(ctx, " \r\n\t>", 5, 1);
- PLIST_XML_ERR("Invalid special tag '<!%.*s>' encountered inside '<%s>' tag\n", (int)(ctx->pos - p), p, tag);
+ PLIST_XML_ERR("Invalid special tag <!%.*s> encountered inside <%s> tag\n", (int)(ctx->pos - p), p, tag);
ctx->err++;
return NULL;
}
@@ -605,7 +605,7 @@ static text_part_t* get_text_parts(parse_ctx ctx, const char* tag, size_t tag_le
} else {
p = ctx->pos;
find_next(ctx, " \r\n\t>", 5, 1);
- PLIST_XML_ERR("Invalid tag '<%.*s>' encountered inside '<%s>' tag\n", (int)(ctx->pos - p), p, tag);
+ PLIST_XML_ERR("Invalid tag <%.*s> encountered inside <%s> tag\n", (int)(ctx->pos - p), p, tag);
ctx->err++;
return NULL;
}
@@ -788,16 +788,16 @@ static char* text_parts_get_content(text_part_t *tp, int unesc_entities, size_t
static void node_from_xml(parse_ctx ctx, plist_t *plist, uint32_t depth)
{
char *keyname = NULL;
+ const char *p = NULL;
while (ctx->pos < ctx->end && !ctx->err) {
-#ifdef DEBUG
- const char *start = ctx->pos;
-#endif
parse_skip_ws(ctx);
if (ctx->pos >= ctx->end) {
break;
}
if (*ctx->pos != '<') {
- PLIST_XML_ERR("Failed to parse XML. Expected: opening tag, found: '%s', pos: %s\n", start, ctx->pos);
+ p = ctx->pos;
+ find_next(ctx, " \t\r\n", 4, 0);
+ PLIST_XML_ERR("Expected: opening tag, found: %.*s\n", (int)(ctx->pos - p), p);
ctx->pos = ctx->end;
ctx->err++;
break;
@@ -856,14 +856,16 @@ static void node_from_xml(parse_ctx ctx, plist_t *plist, uint32_t depth)
ctx->pos += 2;
}
} else {
- PLIST_XML_ERR("Unknown ! special tag encountered\n");
+ p = ctx->pos;
+ find_next(ctx, " \r\n\t>", 5, 1);
+ PLIST_XML_ERR("Invalid special tag <%.*s> encountered\n", (int)(ctx->pos - p), p);
ctx->err++;
}
continue;
} else {
int is_empty = 0;
int closing_tag = 0;
- const char *p = ctx->pos;
+ p = ctx->pos;
find_next(ctx," \r\n\t<>", 6, 0);
if (ctx->pos >= ctx->end) {
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)
return;
}
if (*ctx->pos != '>') {
- PLIST_XML_ERR("Missing '>' for tag '%s'\n", tag);
+ PLIST_XML_ERR("Missing '>' for tag <%s\n", tag);
ctx->pos = ctx->end;
ctx->err++;
free(tag);
@@ -905,6 +907,7 @@ static void node_from_xml(parse_ctx ctx, plist_t *plist, uint32_t depth)
if (!strcmp(tag, "plist")) {
free(tag);
if (is_empty) {
+ PLIST_XML_ERR("Empty plist tag\n");
return;
}
if (!*plist) {
@@ -920,7 +923,7 @@ static void node_from_xml(parse_ctx ctx, plist_t *plist, uint32_t depth)
free(keyname);
return;
} else if (depth == 1 && *plist) {
- PLIST_XML_ERR("Unexpected tag %s found while /plist is expected\n", tag);
+ PLIST_XML_ERR("Unexpected tag <%s> found while </plist> is expected\n", tag);
ctx->err++;
free(tag);
free(keyname);
@@ -1151,7 +1154,7 @@ static void node_from_xml(parse_ctx ctx, plist_t *plist, uint32_t depth)
} else if (tag[0] == '/') {
closing_tag = 1;
} else {
- PLIST_XML_ERR("Unexpected tag '<%s%s>' encountered while parsing XML\n", tag, (is_empty) ? "/" : "");
+ PLIST_XML_ERR("Unexpected tag <%s%s> encountered\n", tag, (is_empty) ? "/" : "");
ctx->pos = ctx->end;
ctx->err++;
free(tag);
@@ -1219,13 +1222,13 @@ static void node_from_xml(parse_ctx ctx, plist_t *plist, uint32_t depth)
PLIST_XML_ERR("missing value node in dict\n");
ctx->err++;
} else if (strcmp(tag+1, XPLIST_DICT) != 0) {
- PLIST_XML_ERR("closing tag mismatch, expected: /%s found: %s\n", XPLIST_DICT, tag);
+ PLIST_XML_ERR("closing tag mismatch, expected: </%s> found: <%s>\n", XPLIST_DICT, tag);
ctx->err++;
}
break;
case PLIST_ARRAY:
if (strcmp(tag+1, XPLIST_ARRAY) != 0) {
- PLIST_XML_ERR("closing tag mismatch, expected: /%s found: %s\n", XPLIST_ARRAY, tag);
+ PLIST_XML_ERR("closing tag mismatch, expected: </%s> found: <%s>\n", XPLIST_ARRAY, tag);
ctx->err++;
}
break;
@@ -1246,7 +1249,7 @@ static void node_from_xml(parse_ctx ctx, plist_t *plist, uint32_t depth)
}
}
if (depth == 1) {
- PLIST_XML_ERR("EOF while /plist tag is expected\n");
+ PLIST_XML_ERR("EOF while </plist> tag is expected\n");
ctx->err++;
}
if (ctx->err) {