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
This commit is contained in:
EliotJones 2025-07-06 17:56:59 -05:00 committed by BobLd
parent daaac9350d
commit 781991b6bf

View File

@ -268,6 +268,12 @@
{
token = trimmedDuplicatedEndTokens[0];
}
else if (readTokens[0] is StreamToken str
&& readTokens.Skip(1).All(x => x is OperatorToken op && op.Equals(OperatorToken.EndStream)))
{
// If a stream token is followed by "endstream" operator tokens just skip the following duplicated tokens.
token = str;
}
else
{
token = readTokens[readTokens.Count - 1];