Commit 431e872
committed
Avoid TypeError on reference resolution
With the previous change deferring reading of objects from the decoded
stream until references can be resolved, it now runs into
jesparza#70. This change provides a different approach in fixing
it to #6 by syncing it with the other locations where the identical code
is in use:
1. Force the numbers extracted by re.findall to int() as before,
avoiding the TypeError exception:
Traceback (most recent call last):
File "peepdf-venv2/lib64/python2.7/site-packages/peepdf/main.py", line 409, in main
ret, pdf = pdfParser.parse(fileName, options.isForceMode, options.isLooseMode, options.isManualAnalysis)
File "peepdf-venv2/lib64/python2.7/site-packages/peepdf/PDFCore.py", line 7117, in parse
ret = body.updateObjects()
File "peepdf-venv2/lib64/python2.7/site-packages/peepdf/PDFCore.py", line 4291, in updateObjects
object.resolveReferences()
File "peepdf-venv2/lib64/python2.7/site-packages/peepdf/PDFCore.py", line 3256, in resolveReferences
ret = PDFParser.readObject(objectsSection[offset:])
TypeError: slice indices must be integers or None or have an __index__ method
2. Instantiate a new PDFParser object by adding the missing braces,
avoiding another TypeError because readObject is no class method:
Traceback (most recent call last):
File "peepdf-venv2/lib64/python2.7/site-packages/peepdf/main.py", line 409, in main
ret, pdf = pdfParser.parse(fileName, options.isForceMode, options.isLooseMode, options.isManualAnalysis)
File "peepdf-venv2/lib64/python2.7/site-packages/peepdf/PDFCore.py", line 7118, in parse
ret = body.updateObjects()
File "peepdf-venv2/lib64/python2.7/site-packages/peepdf/PDFCore.py", line 4292, in updateObjects
object.resolveReferences()
File "peepdf-venv2/lib64/python2.7/site-packages/peepdf/PDFCore.py", line 3256, in resolveReferences
ret = PDFParser.readObject(objectsSection[offset:])
TypeError: unbound method readObject() must be called with PDFParser instance as first argument (got str instance instead)
3. Explicitly force the id to be an int() as well and append it do the
list of indices as at the other callsites of this code. This solves
no issue I have run into but seems sensible to avoid other potential
TypeErrors and keep internal bookkeeping of the object consistent.
This should conclusively resolve jesparza#70 and supersedes #6.
Signed-off-by: Michael Weiser <michael.weiser@gmx.de>1 parent d7f0be5 commit 431e872
1 file changed
Lines changed: 5 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3251 | 3251 | | |
3252 | 3252 | | |
3253 | 3253 | | |
3254 | | - | |
3255 | | - | |
| 3254 | + | |
| 3255 | + | |
| 3256 | + | |
3256 | 3257 | | |
3257 | 3258 | | |
3258 | 3259 | | |
| |||
3261 | 3262 | | |
3262 | 3263 | | |
3263 | 3264 | | |
3264 | | - | |
| 3265 | + | |
| 3266 | + | |
3265 | 3267 | | |
3266 | 3268 | | |
3267 | 3269 | | |
| |||
0 commit comments