Skip to content

Commit

Permalink
PDF: Ignore invalid objid in non-strict mode, fixes #233
Browse files Browse the repository at this point in the history
  • Loading branch information
noDRM committed Dec 29, 2022
1 parent a30405b commit a711954
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion DeDRM_plugin/ineptpdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -1831,7 +1831,19 @@ def getobj(self, objid):
try:
obj = objs[i]
except IndexError:
raise PDFSyntaxError('Invalid object number: objid=%r' % (objid))
# This IndexError used to just raise an exception.
# Unfortunately that seems to break some PDFs, see this issue:
# https://github.com/noDRM/DeDRM_tools/issues/233
# I'm not sure why this is the case, but lets try only raising that exception
# when in STRICT mode, and make it a warning otherwise.
if STRICT:
raise PDFSyntaxError('Invalid object number: objid=%r' % (objid))

print('Invalid object number: objid=%r' % (objid))
print("Continuing anyways?")
print("If the resulting PDF is corrupted, please open a bug report.")
return None

if isinstance(obj, PDFStream):
obj.set_objid(objid, 0)
else:
Expand Down

0 comments on commit a711954

Please sign in to comment.