Skip to content

Unexpected escaped string for a valid PDF. #360

@kaplun

Description

@kaplun

Given the PDF available at: https://export.arxiv.org/pdf/1707.04066v1
the current snippet:

import PyPDF2
pdf = PyPDF2.PdfFileReader("/tmp/1707.04066v1")
pdf.getNamedDestinations()

will crash with:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/skaplun/.virtualenvs/labs3/local/lib/python2.7/site-packages/PyPDF2/pdf.py", line 1312, in getNamedDestinations
    self.getNamedDestinations(kid.getObject(), retval)
  File "/home/skaplun/.virtualenvs/labs3/local/lib/python2.7/site-packages/PyPDF2/generic.py", line 178, in getObject
    return self.pdf.getObject(self).getObject()
  File "/home/skaplun/.virtualenvs/labs3/local/lib/python2.7/site-packages/PyPDF2/pdf.py", line 1611, in getObject
    retval = readObject(self.stream, self)
  File "/home/skaplun/.virtualenvs/labs3/local/lib/python2.7/site-packages/PyPDF2/generic.py", line 66, in readObject
    return DictionaryObject.readFromStream(stream, pdf)
  File "/home/skaplun/.virtualenvs/labs3/local/lib/python2.7/site-packages/PyPDF2/generic.py", line 579, in readFromStream
    value = readObject(stream, pdf)
  File "/home/skaplun/.virtualenvs/labs3/local/lib/python2.7/site-packages/PyPDF2/generic.py", line 71, in readObject
    return ArrayObject.readFromStream(stream, pdf)
  File "/home/skaplun/.virtualenvs/labs3/local/lib/python2.7/site-packages/PyPDF2/generic.py", line 166, in readFromStream
    arr.append(readObject(stream, pdf))
  File "/home/skaplun/.virtualenvs/labs3/local/lib/python2.7/site-packages/PyPDF2/generic.py", line 77, in readObject
    return readStringFromStream(stream)
  File "/home/skaplun/.virtualenvs/labs3/local/lib/python2.7/site-packages/PyPDF2/generic.py", line 390, in readStringFromStream
    raise utils.PdfReadError(r"Unexpected escaped string: %s" % tok)
PyPDF2.utils.PdfReadError: Unexpected escaped string: h

This is with the latest stable release available on PyPI and the latest master

Metadata

Metadata

Assignees

No one assigned

    Labels

    Has MCVEA minimal, complete and verifiable example helps a lot to debug / understand feature requestsis-robustness-issueFrom a users perspective, this is about robustness

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions