Skip to content

Commit

Permalink
ref #166 switched approach to throwing exception and triggering a ful…
Browse files Browse the repository at this point in the history
…l xref scan, instead of silently ignoring problematic xref entry line;
  • Loading branch information
ediweissmann committed May 2, 2024
1 parent d87cfa5 commit b5bfb36
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
11 changes: 4 additions & 7 deletions src/main/java/org/sejda/sambox/input/XrefParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,11 @@ void onEntryFound(XrefEntry entry)
{
if(entry.getByteOffset() < XrefEntry.UNKNOWN_OFFSET)
{
LOG.warn("Ignoring xrefEntry with negative byteOffset: {}", entry);
// throw an error instead of silently skipping to force the XrefFullScanner
throw new IllegalArgumentException("XrefEntry with negative byteOffset: " + entry.getByteOffset());
}
else
{
parser().provider().addEntryIfAbsent(entry);
}



parser().provider().addEntryIfAbsent(entry);
}
};
}
Expand Down
2 changes: 2 additions & 0 deletions src/test/java/org/sejda/sambox/input/PDFParserTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,8 @@ public void testNegativeOffsetXrefEntry() throws IOException

PDFTextStripper textStripper = new PDFTextStripper();
textStripper.getText(doc);

assertTrue(doc.hasParseErrors());
}
}

Expand Down

0 comments on commit b5bfb36

Please sign in to comment.