Skip to content

Commit

Permalink
Search for %%EOF in the last 1024 bytes
Browse files Browse the repository at this point in the history
With full Py3 compatibility.
  • Loading branch information
wolever committed Mar 4, 2014
1 parent f3e820d commit f1d4882
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions PyPDF2/pdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -1245,13 +1245,13 @@ def read(self, stream):
stream.seek(-1, 2)
if not stream.tell():
raise utils.PdfReadError('Cannot read an empty file')
last1K = stream.tell() - 1024 + 1 # offset of last 1024 bytes of stream
line = b_('')
if debug: print(" line:",line)
while not line:
while line[:5] != b_("%%EOF"):
if stream.tell() < last1K:
raise utils.PdfReadError("EOF marker not found")
line = self.readNextEndLine(stream)
if debug: print(" line:",line)
if line[:5] != b_("%%EOF"):
raise utils.PdfReadError("EOF marker not found")
if debug: print(" line:",line)

# find startxref entry - the location of the xref table
line = self.readNextEndLine(stream)
Expand Down

0 comments on commit f1d4882

Please sign in to comment.