-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
BUG: Handle IndirectObject in media boxes #2460
Conversation
The FloatObject constructor swallowed all exceptions, which masked issues where IndirectObject was incorrectly passed into the constructor. Instead, follow the pattern NumberObject does, and only swallow ValueError from malformed PDFs.
If an IndirectObject is passed as a parameter to the RectangleObject constructor, unwrap it so we use the number/float it contains.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #2460 +/- ##
=======================================
Coverage 94.43% 94.43%
=======================================
Files 49 49
Lines 8008 8019 +11
Branches 1616 1618 +2
=======================================
+ Hits 7562 7573 +11
Misses 276 276
Partials 170 170 ☔ View full report in Codecov by Sentry. |
Ensures we only go to a maximum depth, so a malicious PDF cannot get us indefinitely stuck. Also introduces unit tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. LGTM.
alternative solution to py-pdf#2460 fixes py-pdf#2287
I've proposed an alternative that should cover more cases |
Thanks for your proposal. I decided to go with #2464 which covers this issue in a more generic manner. |
Fixes the bug where passing an
IndirectObject
to the constructor ofFloatObject
emitted a warning and resulting in a value of0.0
, rather than an exception being thrown.When an
IndirectObject
is passed to the constructor ofRectangleObject
, unwrap thatIndirectObject
so the number it contains is used; this allows for PDFs with page dimensions that includeIndirectObject
s.Fixes #2287