Skip to content

BUG: Add delimiters to NameObject.renumber_table #3286

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

Merged
merged 2 commits into from
May 13, 2025

Conversation

ztravis
Copy link
Contributor

@ztravis ztravis commented May 12, 2025

Per the spec, name objects cannot contain unescaped delimiters, which include angle, curly and square brackets (currently missing).

I've attached a sample input PDF with a valid, correctly escaped name object. When appending this to a new PdfWriter the output is invalid (incorrectly escaped):

>>> w = PdfWriter()
>>> w.append('nameobj.pdf')
>>> w.write('out.pdf')

out.pdf
nameobj.pdf

@ztravis ztravis force-pushed the bugfix/nameobject-renumber-table branch from e0859f1 to 26ea748 Compare May 12, 2025 18:37
@ztravis ztravis changed the title Add all delimiters to NameObject.renumber_table BUG: Add delimiters to NameObject.renumber_table May 12, 2025
@ztravis ztravis force-pushed the bugfix/nameobject-renumber-table branch from 26ea748 to 1baedeb Compare May 12, 2025 18:39
Copy link

codecov bot commented May 12, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.67%. Comparing base (a1c3366) to head (20c4ac5).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3286   +/-   ##
=======================================
  Coverage   96.67%   96.67%           
=======================================
  Files          53       53           
  Lines        8973     8973           
  Branches     1664     1664           
=======================================
  Hits         8675     8675           
  Misses        176      176           
  Partials      122      122           

☔ View full report in Codecov by Sentry.
📢 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
Copy link
Collaborator

Thanks for the PR. Could you please indicate which section of the PDF reference you are referring to here?

I've attached a sample input PDF with a valid, correctly escaped name object. When appending this to a new PdfWriter the output is invalid (incorrectly escaped):

Do you see any benefits of building a test based on this?

@ztravis
Copy link
Contributor Author

ztravis commented May 12, 2025

In the PDF reference version 1.7 name objects are defined in section 3.2.4, which states:

The name may include any regular characters, but not delimiter or
white-space characters (see Section 3.1, “Lexical Conventions”).

Section 3.1 defines delimiter characters:

The delimiter characters (, ), <, >, [, ], {, }, /, and % are special.

I just added a test, yes!

Copy link
Collaborator

@stefan6419846 stefan6419846 left a comment

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 8c542f3 into py-pdf:main May 13, 2025
16 checks passed
stefan6419846 added a commit that referenced this pull request Jun 1, 2025
## What's new

### New Features (ENH)
- Add basic support for JBIG2 by using jbig2dec (#3163) by @stefan6419846

### Bug Fixes (BUG)
- Fix crashes by removing unnecessary line (#3293) by @larsga
- Add delimiters to NameObject.renumber_table (#3286) by @ztravis

### Robustness (ROB)
- Handle DecodeParms being a NullObject (#3285) by @stefan6419846

### Code Style (STY)
- Update to mypy 1.16.0 (#3300) by @stefan6419846

[Full Changelog](5.5.0...5.6.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