Repository navigation
ROB: Do not crash when the outlines entry is not a dictionary - #4023
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4023 +/- ##
==========================================
+ Coverage 98.01% 98.02% +0.01%
==========================================
Files 57 57
Lines 11162 11165 +3
Branches 2098 2099 +1
==========================================
+ Hits 10940 10945 +5
+ Misses 124 123 -1
+ Partials 98 97 -1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
60d6600 to
275aa0f
Compare
|
Not a behavioural change as far as I can tell. A direct NullObject returns from the branch above, an indirect one is resolved by get_object() before either check, and a dictionary lookup gives back NullObject rather than a bare None. I've added a test covering the direct and indirect null cases so it's pinned. |
|
Added the IDs. |
|
You're right, that name described my change rather than the behaviour. Renamed. |
02fc12c to
3b7370d
Compare
|
Not a behavioural change as far as I can tell. A direct NullObject returns from the branch above, an indirect one is resolved by get_object() before either check, and a dictionary lookup gives back NullObject rather than a bare None. I've added a test covering the direct and indirect null cases so it's pinned. |
|
You're right, that name described my change rather than the behaviour. Renamed. |
3b7370d to
c19fa36
Compare
stefan6419846
left a comment
There was a problem hiding this comment.
It seems like we need another final round of resolving the merge conflicts here to get this merged. There were too many PRs touching the same file section.
_get_outline casts /Outlines to a DictionaryObject and tests /First membership on the result, so a file where that entry holds a number, a string or an array raised 'TypeError: argument of type NumberObject is not iterable' from reader.outline. The dropped is_null_or_none call covered three cases, all still handled: a direct NullObject returns from the branch above it, an indirect reference is resolved by get_object() before either check, and a bare None cannot come out of a dictionary lookup. Both null paths have a test.
c19fa36 to
51fde2c
Compare
|
it's two files now with no unrelated changes, and it's mergeable. |
Since 6.17.0, reader.outline raised "AttributeError: 'NoneType' object has no attribute 'get_object'" when /Outlines referenced an object that is missing or free in the xref table, as in PDF files exported by Google apps such as Slides and Sheets. Such a reference resolves to None, which the is_null_or_none check dropped in py-pdf#4023 covered.
Since 6.17.0, reader.outline raised "AttributeError: 'NoneType' object has no attribute 'get_object'" when /Outlines referenced an object that is missing or free in the xref table, as in PDF files exported by Google apps such as Slides and Sheets. Such a reference resolves to None, which the is_null_or_none check dropped in py-pdf#4023 covered.
Since 6.17.0, reader.outline raised "AttributeError: 'NoneType' object has no attribute 'get_object'" when /Outlines referenced an object that is missing or free in the xref table, as in PDF files exported by Google apps such as Slides and Sheets. Such a reference resolves to None, which the is_null_or_none check dropped in #4023 covered. Closes #4176.
_get_outlinecasts/Outlinesto aDictionaryObjectand tests/Firstmembership on the result:The function already returns an empty outline for a null entry, so one it cannot read is reported and takes the same path.
This is a different line from #4018, which guards a node inside the walk rather than the catalog entry itself.
Reverting the change fails the three new tests