diff --git a/pdfminer/pdfdocument.py b/pdfminer/pdfdocument.py index 009d4677..63cc7fbc 100644 --- a/pdfminer/pdfdocument.py +++ b/pdfminer/pdfdocument.py @@ -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) @@ -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)