Skip to content

Commit

Permalink
ignore XML comments and CDATA sections (for now maybe)
Browse files Browse the repository at this point in the history
  • Loading branch information
recp committed May 15, 2020
1 parent 286bc59 commit 3f0bcf7
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"C_Cpp.default.configurationProvider": "vector-of-bool.cmake-tools"
}
43 changes: 43 additions & 0 deletions include/xml/impl/impl_parse.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,49 @@ xml_parse(const char * __restrict contents, xml_options_t options) {
}
break;
}
case '!': { /* Comment + CTADA */
char c1, c2;

/* comments, skip for now. */
if (p[1] != '\0' && p[1] == '-' && p[2] == '-') {
p = p + 2;
c = *p;
c1 = c2 = '\0';

do {
if (c == '\0')
goto err;

c1 = c2;
c2 = c;
c = *++p;

} while (!(c1 == '-' && c2 == '-' && c == '>'));

pos = beginel;
}

/* CDATA or similar data, skip for now. */
else if (p[1] != '\0' && p[1] == '[') {
p = p + 2;
c = *p;
c1 = c2 = '\0';

do {
if (c == '\0')
goto err;

c1 = c2;
c2 = c;
c = *++p;

} while (!(c1 == ']' && c2 == ']' && c == '>')
&& !(c1 == ']' && c2 == ' ' && c == '>'));

pos = beginel;
}
break;
}
case '?':
/* skip XML header e.g. version line */
if (pos == begintag) {
Expand Down

0 comments on commit 3f0bcf7

Please sign in to comment.