Skip to content

BUG: Reject an odd-length print page range - #4013

Merged
stefan6419846 merged 1 commit into
py-pdf:mainfrom
RavSinghChandan:validate-print-pagerange
Aug 26, 2026
Merged

BUG: Reject an odd-length print page range#4013
stefan6419846 merged 1 commit into
py-pdf:mainfrom
RavSinghChandan:validate-print-pagerange

Conversation

@RavSinghChandan

Copy link
Copy Markdown
Contributor

/PrintPageRange holds first/last page pairs, as the viewer preferences documentation shows:

writer.viewer_preferences.print_pagerange = ArrayObject(
    [NumberObject("1"), NumberObject("10"), NumberObject("20"), NumberObject("30")]
)

An array with an odd number of entries leaves a range without its end, and was written through unchecked.

The check is limited to that key because _set_arr is shared with /Enforce, which has no such constraint. An empty array stays valid.

Reverting the change fails the two new tests

@codecov

codecov Bot commented Aug 25, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.00%. Comparing base (8687d25) to head (8d89881).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4013   +/-   ##
=======================================
  Coverage   98.00%   98.00%           
=======================================
  Files          57       57           
  Lines       11122    11124    +2     
  Branches     2085     2086    +1     
=======================================
+ Hits        10900    10902    +2     
  Misses        124      124           
  Partials       98       98           

☔ 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 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please resolve the merge conflicts.

/PrintPageRange holds first/last page pairs, so an array with an odd number of
entries leaves a range without its end. It was written through unchecked.

The check is limited to that key because _set_arr is shared with /Enforce,
which has no such constraint.
@RavSinghChandan
RavSinghChandan force-pushed the validate-print-pagerange branch from 86d6f3c to 8d89881 Compare August 26, 2026 10:07
@RavSinghChandan

Copy link
Copy Markdown
Contributor Author

Rebased onto main.

@stefan6419846
stefan6419846 merged commit 38170a2 into py-pdf:main Aug 26, 2026
33 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