summaryrefslogtreecommitdiffstats
path: root/DeDRM_plugin
diff options
context:
space:
mode:
authorNoDRM <[email protected]>2022-12-29 19:52:08 +0100
committerNoDRM <[email protected]>2022-12-29 19:52:08 +0100
commita7119543237c0d14db812ad0d6fd9f8d3b49acb7 (patch)
treeafdb48aaad9314d8b4db32eb9ec49db2e6070560 /DeDRM_plugin
parenta30405bebfc99626aeea2ffb20c4b428008221e5 (diff)
PDF: Ignore invalid objid in non-strict mode, fixes #233
Diffstat (limited to 'DeDRM_plugin')
-rwxr-xr-xDeDRM_plugin/ineptpdf.py14
1 files changed, 13 insertions, 1 deletions
diff --git a/DeDRM_plugin/ineptpdf.py b/DeDRM_plugin/ineptpdf.py
index ea509ad..ab48130 100755
--- a/DeDRM_plugin/ineptpdf.py
+++ b/DeDRM_plugin/ineptpdf.py
@@ -1831,7 +1831,19 @@ class PDFDocument(object):
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: