Try Catch while parsing XMP-Metadata

This commit is contained in:
Jochen Bohn
2025-12-15 09:16:59 +01:00
parent d2948c63ac
commit 9db9689095
3 changed files with 18 additions and 1 deletions

View File

@@ -150,7 +150,14 @@ public class PDFValidator extends Validator {
final DocumentBuilder builder = factory.newDocumentBuilder();
final InputSource is = new InputSource(new StringReader(xmp));
docXMP = builder.parse(is);
try {
docXMP = builder.parse(is);
} catch (Exception e) {
context.addResultItem(
new ValidationResultItem(ESeverity.error, "XMP Metadata: Could not parse XMP metadata")
.setSection(10).setPart(EPart.pdf));
throw e;
}
final XPathFactory xpathFactory = XPathFactory.newInstance();