Skip to content

BUG: Handle inline images containing EI sequences#3152

Merged
stefan6419846 merged 4 commits intopy-pdf:mainfrom
stefan6419846:issue3107
Feb 26, 2025
Merged

BUG: Handle inline images containing EI sequences#3152
stefan6419846 merged 4 commits intopy-pdf:mainfrom
stefan6419846:issue3107

Conversation

@stefan6419846
Copy link
Copy Markdown
Collaborator

Closes #3107.

@codecov
Copy link
Copy Markdown

codecov bot commented Feb 24, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.52%. Comparing base (038662a) to head (8253fdf).
Report is 103 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3152      +/-   ##
==========================================
+ Coverage   96.51%   96.52%   +0.01%     
==========================================
  Files          53       53              
  Lines        8875     8903      +28     
  Branches     1622     1631       +9     
==========================================
+ Hits         8566     8594      +28     
  Misses        185      185              
  Partials      124      124              

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

@j-t-1
Copy link
Copy Markdown
Contributor

j-t-1 commented Feb 25, 2025

Nice.

is_followed_by_binary_data(stream: IO[bytes], length: int = 10)

Remove spaces around =?

@j-t-1
Copy link
Copy Markdown
Contributor

j-t-1 commented Feb 25, 2025

if byte < 32 and byte not in WHITESPACES_AS_BYTES:
            # This covers all characters not being displayable directly.

Suggestion for amending the comment:
C0 control codes except those defined as PDF whitespace characters.

Are the C1 control codes needed in the if statement?

@stefan6419846
Copy link
Copy Markdown
Collaborator Author

Remove spaces around =?

This will fail linting (ruff) as the whitespace is indeed correct here.

C0 control codes except those defined as PDF whitespace characters.

Are the C1 control codes needed in the if statement?

Yes, I might update the comment. But I am having some troubles understanding what you mean by C0 and C1 control codes - what are you referring to?

@j-t-1
Copy link
Copy Markdown
Contributor

j-t-1 commented Feb 25, 2025

@stefan6419846
Copy link
Copy Markdown
Collaborator Author

Thanks for the link. I am not completely sure about this, but as the value 32_10 = 0x20 is the same as used by iText, this seems like the easiest approach for now. If we have an actual example where the C1 control codes are relevant, we might reconsider this in the future, but for now, this PR should fix this rare edge case in most conditions due to the additional operator guessing logic.

@stefan6419846 stefan6419846 merged commit 0714711 into py-pdf:main Feb 26, 2025
16 checks passed
@stefan6419846 stefan6419846 deleted the issue3107 branch February 26, 2025 12:21
stefan6419846 added a commit that referenced this pull request Mar 2, 2025
## What's new

### Bug Fixes (BUG)
- Use the correct name StandardEncoding for the predefined cmap (#3156) by @stefan6419846
- Handle inline images containing `EI ` sequences (#3152) by @stefan6419846
- Fix check box value which should be name object (#3124) by @stefan6419846
- Fix stream position on inline image fallback extraction (#3120) by @stefan6419846
- Fix object count for incremental writer (#3117) by @m32

### Robustness (ROB)
- Avoid index errors on empty lines in xref table (#3162) by @stefan6419846
- Improve handling of LZW decoder table overflow (#3159) by @stefan6419846
- Ignore non-numbers for width when building font width map (#3158) by @stefan6419846
- Avoid negative seek values when reading partially broken files (#3157) by @stefan6419846

### Documentation (DOC)
- Fixed PageObject.images example usage for replacing image (#3149) by @jutoth

[Full Changelog](5.3.0...5.3.1)
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.

Insufficient handling of inline images containing EI sequences

2 participants