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

ROB: Capture UnicodeDecodeError at PdfReader.pdf_header #1759

Closed
wants to merge 2 commits into from

Conversation

MartinThoma
Copy link
Member

@MartinThoma MartinThoma commented Mar 31, 2023

Closes #1758

@codecov
Copy link

codecov bot commented Mar 31, 2023

Codecov Report

Patch coverage: 100.00% and no project coverage change.

Comparison is base (1563e8e) 92.41% compared to head (38fe3ee) 92.41%.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1759   +/-   ##
=======================================
  Coverage   92.41%   92.41%           
=======================================
  Files          34       34           
  Lines        6575     6579    +4     
  Branches     1301     1301           
=======================================
+ Hits         6076     6080    +4     
  Misses        326      326           
  Partials      173      173           
Impacted Files Coverage Δ
pypdf/_reader.py 91.22% <100.00%> (+0.02%) ⬆️
pypdf/_writer.py 86.15% <100.00%> (+0.01%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

Copy link
Collaborator

@pubpub-zz pubpub-zz left a comment

Choose a reason for hiding this comment

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

I'm very confused about this PR : if the message can not be decoded it means it does not respect the standard, and having such an exception seems for me acceptable. If there is realy a problem, I would use use decode with 'backslashreplace' to have a better understanding of the non recognised 'magic' and eventy raise an error.

@MartinThoma
Copy link
Member Author

I think I've noticed pdfs in the past where the version was not set (correctly), but the remaining document was just fine

@pubpub-zz
Copy link
Collaborator

I think I've noticed pdfs in the past where the version was not set (correctly), but the remaining document was just fine

so what about just using backslashreplace to be tolerant but still able to read the magic ?

@MartinThoma
Copy link
Member Author

#1768 is a better solution.

@MartinThoma MartinThoma closed this Apr 6, 2023
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.

UnicodeDecodeError 'utf-8' codec can't decode byte 0xac in position 0: invalid start byte
2 participants