Skip to content
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

BUG: Handle inline images containing EI sequences #3152

Merged
merged 4 commits into from
Feb 26, 2025

Conversation

stefan6419846
Copy link
Collaborator

Closes #3107.

Copy link

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

@j-t-1
Copy link
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
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
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
Contributor

j-t-1 commented Feb 25, 2025

@stefan6419846
Copy link
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