mirror of
https://github.com/UglyToad/PdfPig.git
synced 2025-10-15 19:54:52 +08:00
continue searching for xref tokens even if an %%eof is encountered #38
This commit is contained in:
@@ -3,10 +3,8 @@ namespace UglyToad.PdfPig.Tests.Integration
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using Content;
|
||||
using Xunit;
|
||||
|
||||
|
@@ -31,7 +31,7 @@ startxref
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void IgnoresStartXrefFollowingEndOfFile()
|
||||
public void IncludesStartXrefFollowingEndOfFile()
|
||||
{
|
||||
var input = StringBytesTestConverter.Convert(@"11 0 obj
|
||||
<< /Type/Something /W[12 0 5 6] >>
|
||||
@@ -53,7 +53,7 @@ startxref
|
||||
|
||||
var result = parser.GetFirstCrossReferenceOffset(input.Bytes, new CoreTokenScanner(input.Bytes), false);
|
||||
|
||||
Assert.Equal(1384733, result);
|
||||
Assert.Equal(17, result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
@@ -27,15 +27,6 @@
|
||||
/// </summary>
|
||||
private const int EndOfFileSearchRange = 1024;
|
||||
|
||||
private static readonly byte[] EndOfFileBytes =
|
||||
{
|
||||
(byte)'%',
|
||||
(byte)'%',
|
||||
(byte)'E',
|
||||
(byte)'O',
|
||||
(byte)'F'
|
||||
};
|
||||
|
||||
private static readonly byte[] StartXRefBytes =
|
||||
{
|
||||
(byte) 's',
|
||||
@@ -106,7 +97,6 @@
|
||||
var startXrefs = new List<int>();
|
||||
|
||||
var index = 0;
|
||||
var eofIndex = 0;
|
||||
var offset = 0;
|
||||
|
||||
// Starting scanning the last 1024 bytes.
|
||||
@@ -116,18 +106,10 @@
|
||||
if (bytes.CurrentByte == StartXRefBytes[index])
|
||||
{
|
||||
// We might be reading "startxref".
|
||||
eofIndex = 0;
|
||||
index++;
|
||||
}
|
||||
else if (bytes.CurrentByte == EndOfFileBytes[eofIndex])
|
||||
{
|
||||
// We might be reading "%%EOF".
|
||||
eofIndex++;
|
||||
index = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
eofIndex = 0;
|
||||
index = 0;
|
||||
}
|
||||
|
||||
@@ -139,11 +121,6 @@
|
||||
// Continue scanning in case there are further "startxref"s. Not sure if this ever happens.
|
||||
index = 0;
|
||||
}
|
||||
else if (eofIndex == EndOfFileBytes.Length)
|
||||
{
|
||||
// Stop at the EOF if present.
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (startXrefs.Count == 0)
|
||||
|
Reference in New Issue
Block a user