Skip to content

Commit

Permalink
IsValidXref() no will no longer check if it's inside of a stream beyo…
Browse files Browse the repository at this point in the history
…ng an EOF symbol.
  • Loading branch information
mlaukala committed Nov 14, 2017
1 parent 15ac2bb commit d6337ee
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions src/PdfSharp/Pdf.IO/Parser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1088,17 +1088,21 @@ private bool IsValidXref()
content += _lexer.ReadRawString(content_pos, read_length);

int ss = content.IndexOf("stream", StringComparison.Ordinal);
int eof = content.IndexOf("%%EOF", StringComparison.Ordinal);
int es = content.IndexOf("endstream", StringComparison.Ordinal);

if (ss < es)
{
// Not inside of stream
break;
}
else if (es != -1 && ss > es)
int s = Math.Min(ss, eof);

if (s != es)
{
// inside of stream
return false;
if (s == -1)
return false;
else if (es == -1)
break;
else if (s < es)
break;
else if (s > es)
return false;
}

content_pos = content_pos + read_length;
Expand Down

0 comments on commit d6337ee

Please sign in to comment.