Skip to content
Merged
Show file tree
Hide file tree
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
23 changes: 23 additions & 0 deletions src/UglyToad.PdfPig.Tests/Integration/GithubIssuesTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,32 @@
using Content;
using DocumentLayoutAnalysis.PageSegmenter;
using DocumentLayoutAnalysis.WordExtractor;
using PdfPig.Core;

public class GithubIssuesTests
{
[Fact]
public void Issue959()
{
// Lenient parsing ON
var path = IntegrationHelpers.GetSpecificTestDocumentPath("algo.pdf");
using (var document = PdfDocument.Open(path, new ParsingOptions() { UseLenientParsing = true }))
{
for (int i = 1; i <= document.NumberOfPages; ++i)
{
var page = document.GetPage(i);
Assert.NotNull(page);
Assert.Equal(i, page.Number);
}
}

// Lenient parsing OFF
var exception = Assert.Throws<PdfDocumentFormatException>(() =>
PdfDocument.Open(path, new ParsingOptions() { UseLenientParsing = false }));

Assert.Equal("The cross references formed an infinite loop.", exception.Message);
}

[Fact]
public void Issue945()
{
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,12 @@ public CrossReferenceTable Parse(IInputBytes bytes, bool isLenientParsing, long

if (prevSet.Contains(previousCrossReferenceLocation))
{
if (isLenientParsing)
{
log.Error("The cross references formed an infinite loop.");
break;
}

throw new PdfDocumentFormatException("The cross references formed an infinite loop.");
}

Expand Down
Loading