Fix bug with validator hanging on some XML instances

This commit is contained in:
Grahame Grieve 2022-09-07 08:11:09 +10:00
parent 44aeaa1a80
commit c3ab401f56
1 changed files with 8 additions and 7 deletions

View File

@ -307,15 +307,16 @@ public class XmlParser extends ParserBase {
Node n = node.getFirstChild();
while (n != null) {
if (n.getNodeType() == Node.TEXT_NODE && !Utilities.noString(n.getTextContent().trim())) {
while (n.getNextSibling() != null && n.getNodeType() != Node.ELEMENT_NODE) {
n = n.getNextSibling();
Node nt = n;
while (nt.getNextSibling() != null && nt.getNodeType() != Node.ELEMENT_NODE) {
nt = nt.getNextSibling();
}
while (n.getPreviousSibling() != null && n.getNodeType() != Node.ELEMENT_NODE) {
n = n.getPreviousSibling();
while (nt.getPreviousSibling() != null && nt.getNodeType() != Node.ELEMENT_NODE) {
nt = nt.getPreviousSibling();
}
line = line(n);
col = col(n);
logError(line, col, path, IssueType.STRUCTURE, context.formatMessage(I18nConstants.TEXT_SHOULD_NOT_BE_PRESENT, text), IssueSeverity.ERROR);
line = line(nt);
col = col(nt);
logError(line, col, path, IssueType.STRUCTURE, context.formatMessage(I18nConstants.TEXT_SHOULD_NOT_BE_PRESENT, Utilities.makeSingleLine(text)), IssueSeverity.ERROR);
}
n = n.getNextSibling();
}