Skip to content
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

Make sure to dereference MediaBox in /Pages #1027

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- `RecursionError` when corrupt PDF specifies a recursive /Pages object ([#998](https://github.com/pdfminer/pdfminer.six/pull/998))
- `TypeError` when corrupt PDF specifies text-positioning operators with invalid values ([#1000](https://github.com/pdfminer/pdfminer.six/pull/1000))
- inline image parsing fails when stream data contains "EI\n" ([#1008](https://github.com/pdfminer/pdfminer.six/issues/1008))
- `TypeError` when MediaBox is an indirect object reference ([#1004](https://github.com/pdfminer/pdfminer.six/issues/1004))

### Removed

Expand Down
3 changes: 2 additions & 1 deletion pdfminer/pdfpage.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ def __init__(
self.attrs.get("Resources", dict()),
)
mediabox_params: List[Any] = [
resolve1(mediabox_param) for mediabox_param in self.attrs["MediaBox"]
resolve1(mediabox_param)
for mediabox_param in resolve1(self.attrs["MediaBox"])
dhdaines marked this conversation as resolved.
Show resolved Hide resolved
]
self.mediabox = parse_rect(resolve1(mediabox_params))
self.cropbox = self.mediabox
Expand Down
Binary file added samples/contrib/issue-1004-indirect-mediabox.pdf
Binary file not shown.
4 changes: 4 additions & 0 deletions tests/test_tools_pdf2txt.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,10 @@ def test_html_simple1(self):
def test_hocr_simple1(self):
run("simple1.pdf", "-t hocr")

def test_contrib_issue_1004_mediabox(self):
"""Verify that we do not crash with MediaBox is an object reference"""
run("contrib/issue-1004-indirect-mediabox.pdf")


class TestDumpImages:
@staticmethod
Expand Down
Loading