Skip to content

Commit

Permalink
fix: ensure that bytes is actually bytes (fixes: pdfminer#1059)
Browse files Browse the repository at this point in the history
  • Loading branch information
dhdaines committed Nov 27, 2024
1 parent 1a8bd2f commit 7e1e281
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pdfminer/pdfdevice.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ def render_string_horizontal(
if isinstance(obj, (int, float)):
x -= obj * dxscale
needcharspace = True
else:
elif isinstance(obj, bytes):
for cid in font.decode(obj):
if needcharspace:
x += charspace
Expand Down Expand Up @@ -207,7 +207,7 @@ def render_string_vertical(
if isinstance(obj, (int, float)):
y -= obj * dxscale
needcharspace = True
else:
elif isinstance(obj, bytes):
for cid in font.decode(obj):
if needcharspace:
y += charspace
Expand Down
Binary file added samples/contrib/issue-1059-cmap-decode.pdf
Binary file not shown.
6 changes: 6 additions & 0 deletions tests/test_tools_pdf2txt.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@ def test_contrib_issue_350(self):
"""
run("contrib/issue-00352-asw-oct96-p41.pdf")

def test_contrib_issue_1059_textseq(self):
"""Ensure that CMaps are robust to non-strings in text
sequences
(https://github.com/pdfminer/pdfminer.six/issues/1059)."""
run("contrib/issue-1059-cmap-decode.pdf")

def test_scancode_patchelf(self):
"""Regression test for https://github.com/euske/pdfminer/issues/96"""
run("scancode/patchelf.pdf")
Expand Down

0 comments on commit 7e1e281

Please sign in to comment.