Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,18 @@ public PDFValidator(ValidationContext ctx) {
private static final Logger LOGGER = LoggerFactory.getLogger(PDFValidator.class.getCanonicalName()); // log output
private static final PDFAFlavour[] PDF_A_3_FLAVOURS = {PDFAFlavour.PDFA_3_A, PDFAFlavour.PDFA_3_B, PDFAFlavour.PDFA_3_U};

private static String escapeXmlSpecialChars(String value) {
if (value == null || value.isEmpty()) {
return value;
}
return value
.replace("&", "&")
.replace("<", "&lt;")
.replace(">", "&gt;")
.replace("\"", "&quot;")
.replace("'", "&apos;");
}

private String pdfFilename;

private byte[] fileContents;
Expand Down Expand Up @@ -113,10 +125,10 @@ public void validate() throws IrrecoverableValidationError {
ItemDetails itemDetails = ItemDetails.fromValues(pdfFilename);
inputStream.mark(Integer.MAX_VALUE);
processorResult = processor.process(itemDetails, inputStream);
pdfReport = processorResult.getValidationResult().toString().replaceAll(
pdfReport = escapeXmlSpecialChars(processorResult.getValidationResult().toString().replaceAll(
"<\\?xml version=\"1\\.0\" encoding=\"utf-8\"\\?>",
""
);
));
inputStream.reset();
} catch (final Exception excep) {
context.addResultItem(new ValidationResultItem(ESeverity.exception, excep.getMessage()).setSection(7)
Expand Down
Loading