Skip to content

BUG: Parse a string rect for add_uri into a rectangle - #4074

Merged
stefan6419846 merged 1 commit into
py-pdf:mainfrom
RavSinghChandan:add-uri-string-rect
Sep 14, 2026
Merged

stefan6419846 merged 1 commit into
py-pdf:mainfrom
RavSinghChandan:add-uri-string-rect

Conversation

@RavSinghChandan

Copy link
Copy Markdown
Contributor

add_uri documents its rect argument as accepting the string form
"[ xLL yLL xUR yUR ]", but a string was wrapped in a single NumberObject:

add_uri(0, "https://example.com", "[ 0 0 100 100 ]")

NumberObject cannot parse that, so it warned and fell back to 0 — the
annotation's /Rect became a single 0 instead of a rectangle, leaving the link
with no clickable area. RectangleObject and list forms were unaffected.

The string is now split into its four numbers and built into a RectangleObject,
matching the documented behaviour and the other two input forms.

The existing test_add_uri already passed a string rect but never checked the
result; it now asserts the /Rect for both the string and list forms.

Offline suite passes, 1339 tests.

Used Claude (Opus) to help locate and patch this; I reviewed and tested the change.

@codecov

codecov Bot commented Sep 11, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.12%. Comparing base (d26df36) to head (e2ef440).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4074   +/-   ##
=======================================
  Coverage   98.11%   98.12%           
=======================================
  Files          59       59           
  Lines       11489    11490    +1     
  Branches     2150     2150           
=======================================
+ Hits        11273    11274    +1     
  Misses        122      122           
  Partials       94       94           

☔ 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.

Thanks.

@stefan6419846
stefan6419846 merged commit 3a1111d into py-pdf:main Sep 14, 2026
33 of 48 checks passed
stefan6419846 added a commit that referenced this pull request Sep 16, 2026
## What's new

### Security (SEC)
- Limit size of alphabetical page labels (#4096) by @stefan6419846

### Deprecations (DEP)
- Replace PdfWriter method add_js (#3979) by @j-t-1

### Performance Improvements (PI)
- Move static value out of loop body for appearance stream data (#4087) by @stefan6419846
- Reduce number of full data lookups for attachment mapping API (#4081) by @stefan6419846

### Bug Fixes (BUG)
- Do not copy unrelated pages when appending pages with non-terminal fields (#4078) by @anandghegde
- Use page reference for existing internal link targets (#4076) by @r-kamei
- Arabic-Indic digits are reversed during text extraction (#4077) by @Syamjith-NK
- Parse a string rect for add_uri into a rectangle (#4074) by @RavSinghChandan

[Full Changelog](6.18.1...6.19.0)
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