Skip to content

Commit

Permalink
Resist to badly formatted XML file when parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
Jean Francois Denise committed Apr 2, 2024
1 parent 19b1bde commit c394b68
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion core/src/main/java/org/wildfly/glow/DeploymentScanner.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@
import java.util.stream.Collectors;

import static org.objectweb.asm.Opcodes.ASM9;
import org.wildfly.glow.error.ErrorLevel;
import org.wildfly.glow.error.IdentifiedError;

public class DeploymentScanner implements AutoCloseable {

Expand Down Expand Up @@ -629,7 +631,20 @@ Set<Layer> inspectDeployment(Path rootPath,
if (k.startsWith(LayerMetadata.XML_PATH)) {
ParsedRule rule = inspector.extractParsedRule(val);
rule.iterateMatchedPaths((path, values) -> {
Utils.applyXPath(path, values.get(0).getValue(), values.size() == 1 ? null : values.get(1).getValue(), consumer, l);
try {
Utils.applyXPath(path, values.get(0).getValue(), values.size() == 1 ? null : values.get(1).getValue(), consumer, l);
} catch(Exception ex) {
String id = "invalidXML" + path;
boolean allreadySet = false;
for (IdentifiedError err : ctx.errorSession.getErrors()) {
if (id.equals(err.getId())) {
allreadySet = true;
}
}
if (!allreadySet) {
ctx.errorSession.addError(new IdentifiedError(id, "Exception parsing " + path + ": " + ex, ErrorLevel.WARN));
}
}
});
} else if (k.startsWith(LayerMetadata.PROPERTIES_FILE_MATCH)) {
ParsedRule parsedRule = inspector.extractParsedRule(val);
Expand Down

0 comments on commit c394b68

Please sign in to comment.