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

Prevent embedded file streams from being bytes #650

Closed
wants to merge 1 commit into from

Conversation

Tontyna
Copy link
Contributor

@Tontyna Tontyna commented Jun 25, 2018

Should fix #644

@liZe
Copy link
Member

liZe commented Jun 26, 2018

As

  • pdf_file_object.stream is initially an empty str
  • decode always returns str objects
  • adding str and bytes objects raises an exception,

I don't know how we could ever get a bytes object here!

@Tontyna
Copy link
Contributor Author

Tontyna commented Jun 26, 2018

I don't know whether we ever get a bytes object from decode (zlib is built-in, cannot debug), it was just an idea. It was just an experiment. And by forcing the stream to bytes the embedded stream in the PDF was changed into b'....', exactly what the buggy PDFs contain.

No exceptions here. Neither with pdf_file_object.stream = str(pdf_file_object.stream) nor with pdf_file_object.stream = bytes(pdf_file_object.stream, 'latin-1').

BTW: My pdfrw version is 0.4

@liZe
Copy link
Member

liZe commented Jun 26, 2018

I don't know whether we ever get a bytes object from decode (zlib is built-in, cannot debug), it was just an idea. It was just an experiment.

No problem 😉.

The bug is in 0.42.3 but is already fixed in master. I've backported the fix into the 0.x branch (as written in #644) and I'll release a new 0.x version later.

@liZe liZe closed this Jun 26, 2018
@Tontyna
Copy link
Contributor Author

Tontyna commented Jun 26, 2018

Ah, got it -- I (of course?) used the master branch when exploring the issue...

@Tontyna Tontyna deleted the attachments branch June 26, 2018 10:02
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.

I can attach files via command line api but not the python api?
2 participants