mirror of
https://github.com/UglyToad/PdfPig.git
synced 2025-04-05 20:55:01 +08:00
Do not throw exception when lenient parsing in ON in CrossReferenceParser and fix #959
This commit is contained in:
parent
7ec4e692a9
commit
50dca593da
@ -3,9 +3,32 @@
|
|||||||
using Content;
|
using Content;
|
||||||
using DocumentLayoutAnalysis.PageSegmenter;
|
using DocumentLayoutAnalysis.PageSegmenter;
|
||||||
using DocumentLayoutAnalysis.WordExtractor;
|
using DocumentLayoutAnalysis.WordExtractor;
|
||||||
|
using PdfPig.Core;
|
||||||
|
|
||||||
public class GithubIssuesTests
|
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]
|
[Fact]
|
||||||
public void Issue945()
|
public void Issue945()
|
||||||
{
|
{
|
||||||
|
138721
src/UglyToad.PdfPig.Tests/Integration/SpecificTestDocuments/algo.pdf
Normal file
138721
src/UglyToad.PdfPig.Tests/Integration/SpecificTestDocuments/algo.pdf
Normal file
File diff suppressed because one or more lines are too long
@ -226,6 +226,12 @@
|
|||||||
|
|
||||||
if (prevSet.Contains(previousCrossReferenceLocation))
|
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.");
|
throw new PdfDocumentFormatException("The cross references formed an infinite loop.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user