diff --git a/lib/parse.cpp b/lib/parse.cpp index c6fcfd0d05..e2b7b4b335 100644 --- a/lib/parse.cpp +++ b/lib/parse.cpp @@ -801,20 +801,27 @@ bool XML_PARSER::parse_start(const char* start_tag) { void XML_PARSER::skip_unexpected( const char* start_tag, bool verbose, const char* where ) { - char buf[MAX_XML_STRING], end_tag[TAG_BUF_LEN]; + char buf[TAG_BUF_LEN], end_tag[TAG_BUF_LEN]; if (verbose) { - fprintf(stderr, "Unrecognized XML in %s: %s\n", where, start_tag); + fprintf(stderr, + "Unrecognized XML tag '<%s>' in %s; skipping\n", + start_tag, where + ); } if (strchr(start_tag, '/')) return; sprintf(end_tag, "/%s", start_tag); - while (!get(buf, sizeof(buf), is_tag)) { - if (verbose) { - fprintf(stderr, "Skipping: is_tag %d %s\n", is_tag, buf); + + while (1) { + int c; + bool eof = scan_nonws(c); + if (eof) return; + if (c == '<') { + int retval = scan_tag(buf, sizeof(buf), 0, 0); + if (retval != XML_PARSE_TAG) continue; + if (!strcmp(buf, end_tag)) return; + skip_unexpected(buf, false, where); } - if (!is_tag) continue; - if (!strcmp(buf, end_tag)) return; - skip_unexpected(buf, false, where); } } diff --git a/lib/parse_test.cpp b/lib/parse_test.cpp index 8c05b6b0bf..925f113984 100644 --- a/lib/parse_test.cpp +++ b/lib/parse_test.cpp @@ -20,6 +20,7 @@ void parse(FILE* f) { } strcpy(foo, "xxx"); while (!xp.get_tag()) { + printf("get_tag(): is_tag %d text %s\n", xp.is_tag, xp.parsed_tag); if (!xp.is_tag) { printf("unexpected text: %s\n", xp.parsed_tag); continue;