cross reference offset is in the xref table we ignore the error

previously we checked the offset was not inside the table (correct thing to check), however this is only a special case of the more general issue (cross reference offsets are wrong). we move handling for this into the pdf token scanner. if we attempt to read an object at an offset and it fails we brute force the entire file to find correct offsets. we also needed to add handling to make sure we don't attempt to use stream length tokens if we're brute-forcing since we can't look up indirect references for length.
This commit is contained in:
Eliot Jones
2020-02-26 14:03:46 +00:00
parent 7d0d5806a9
commit f415c3116e
3 changed files with 33 additions and 22 deletions

View File

@@ -227,7 +227,7 @@ trailer
}
[Fact]
public void EntryPointingAtOffsetInTableThrows()
public void EntryPointingAtOffsetInTableDoesNotThrow()
{
var input = GetReader(@"xref
0 2
@@ -236,9 +236,10 @@ trailer
trailer
<<>>");
Action action = () => parser.Parse(input, 0, false);
var result = parser.Parse(input, 0, false);
Assert.Throws<PdfDocumentFormatException>(action);
var offset = Assert.Single(result.ObjectOffsets);
Assert.Equal(10, offset.Value);
}
[Fact]