Skip to content

Commit

Permalink
close #166 Parse documents with negative byte offset for inUse xref e…
Browse files Browse the repository at this point in the history
…ntry
  • Loading branch information
ediweissmann committed May 2, 2024
1 parent d382bf5 commit c6a5ca6
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/main/java/org/sejda/sambox/input/XrefParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,16 @@ void onTrailerFound(COSDictionary found)
@Override
void onEntryFound(XrefEntry entry)
{
parser().provider().addEntryIfAbsent(entry);
if(entry.getByteOffset() < XrefEntry.UNKNOWN_OFFSET)
{
LOG.warn("Ignoring xrefEntry inUse with byteOffset: {}", entry);
}
else
{
parser().provider().addEntryIfAbsent(entry);
}


}
};
}
Expand Down
12 changes: 12 additions & 0 deletions src/test/java/org/sejda/sambox/input/PDFParserTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,18 @@ public void testPDFBOX4372() throws IOException
}
}

@Test
public void testNegativeOffsetXrefEntry() throws IOException
{
try (PDDocument doc = PDFParser.parse(SeekableSources.inMemorySeekableSourceFrom(
getClass().getResourceAsStream("/sambox/test_multiple_xref_tables_negative_offset.pdf"))))
{

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

//https://lists.apache.org/thread/rmvn7t4bj4d8wsln722kdk39k4fc0ff7
@Test
public void noLoopOrOOM() throws IOException
Expand Down

0 comments on commit c6a5ca6

Please sign in to comment.