Skip to content

Commit

Permalink
Store stripped line
Browse files Browse the repository at this point in the history
  • Loading branch information
jstockwin committed Oct 26, 2020
1 parent 7a11049 commit 23e53c2
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions pdfminer/pdfdocument.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,16 +93,17 @@ def load(self, parser):
while True:
try:
(pos, line) = parser.nextline()
if not line.strip():
stripped_line = line.strip()
if not stripped_line:
continue
except PSEOF:
raise PDFNoValidXRef('Unexpected EOF - file corrupted?')
if not line:
raise PDFNoValidXRef('Premature eof: %r' % parser)
if line.strip().startswith(b'trailer'):
if stripped_line.startswith(b'trailer'):
parser.seek(pos)
break
f = line.strip().split(b' ')
f = stripped_line.split(b' ')
if len(f) != 2:
error_msg = 'Trailer not found: {!r}: line={!r}'\
.format(parser, line)
Expand All @@ -118,7 +119,7 @@ def load(self, parser):
(_, line) = parser.nextline()
except PSEOF:
raise PDFNoValidXRef('Unexpected EOF - file corrupted?')
f = line.strip().split(b' ')
f = stripped_line.split(b' ')
if len(f) != 3:
error_msg = 'Invalid XRef format: {!r}, line={!r}'\
.format(parser, line)
Expand Down

0 comments on commit 23e53c2

Please sign in to comment.