Skip to content

Commit 781991b

Browse files
EliotJonesBobLd
authored andcommitted
fix #670 by ignoring duplicate endstream definitions
when parsing a stream object with multiple endstream tokens the last parsed token was selected instead of the actual stream token so instead we just skip all following tokens if the first is a stream and the following tokens are `endstream` operators only
1 parent daaac93 commit 781991b

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/UglyToad.PdfPig/Tokenization/Scanner/PdfTokenScanner.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,12 @@ public bool MoveNext()
268268
{
269269
token = trimmedDuplicatedEndTokens[0];
270270
}
271+
else if (readTokens[0] is StreamToken str
272+
&& readTokens.Skip(1).All(x => x is OperatorToken op && op.Equals(OperatorToken.EndStream)))
273+
{
274+
// If a stream token is followed by "endstream" operator tokens just skip the following duplicated tokens.
275+
token = str;
276+
}
271277
else
272278
{
273279
token = readTokens[readTokens.Count - 1];

0 commit comments

Comments
 (0)