Skip to content

ROB: Guard text operators against missing operands in extract_text#3861

Merged
stefan6419846 merged 1 commit into
py-pdf:mainfrom
metsw24-max:text-operator-operands
Jun 16, 2026
Merged

ROB: Guard text operators against missing operands in extract_text#3861
stefan6419846 merged 1 commit into
py-pdf:mainfrom
metsw24-max:text-operator-operands

Conversation

@metsw24-max

Copy link
Copy Markdown
Contributor

Crash on text operators with missing operands

A malformed content stream whose ", TD, Td or Tf operator supplies fewer operands than the operator needs makes extract_text() raise an uncaught IndexError (the " case can also surface as a ValueError), because the operands are read by fixed index with no arity check. Guarded each access where it is read so a short operator is skipped or falls back to a zero translation, matching the if operands else handling already used on the neighbouring text-state operators.

@stefan6419846 stefan6419846 changed the title ROB: guard text operators against missing operands in extract_text ROB: Guard text operators against missing operands in extract_text Jun 16, 2026
@codecov

codecov Bot commented Jun 16, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.79%. Comparing base (41a9c3c) to head (a01bdc0).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3861   +/-   ##
=======================================
  Coverage   97.79%   97.79%           
=======================================
  Files          55       55           
  Lines       10509    10510    +1     
  Branches     1958     1958           
=======================================
+ Hits        10277    10278    +1     
  Misses        128      128           
  Partials      104      104           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@stefan6419846 stefan6419846 merged commit d5cd266 into py-pdf:main Jun 16, 2026
24 of 34 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants