Skip to content

Commit d6337ee

Browse files
committed
IsValidXref() no will no longer check if it's inside of a stream beyong an EOF symbol.
1 parent 15ac2bb commit d6337ee

1 file changed

Lines changed: 12 additions & 8 deletions

File tree

src/PdfSharp/Pdf.IO/Parser.cs

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1088,17 +1088,21 @@ private bool IsValidXref()
10881088
content += _lexer.ReadRawString(content_pos, read_length);
10891089

10901090
int ss = content.IndexOf("stream", StringComparison.Ordinal);
1091+
int eof = content.IndexOf("%%EOF", StringComparison.Ordinal);
10911092
int es = content.IndexOf("endstream", StringComparison.Ordinal);
10921093

1093-
if (ss < es)
1094-
{
1095-
// Not inside of stream
1096-
break;
1097-
}
1098-
else if (es != -1 && ss > es)
1094+
int s = Math.Min(ss, eof);
1095+
1096+
if (s != es)
10991097
{
1100-
// inside of stream
1101-
return false;
1098+
if (s == -1)
1099+
return false;
1100+
else if (es == -1)
1101+
break;
1102+
else if (s < es)
1103+
break;
1104+
else if (s > es)
1105+
return false;
11021106
}
11031107

11041108
content_pos = content_pos + read_length;

0 commit comments

Comments
 (0)