-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Improved performance and security for ContentStream_readInlineImage. #740
Conversation
@MasterOdin What do you think about the PR? Do you see anything that this could break? |
Codecov Report
@@ Coverage Diff @@
## main #740 +/- ##
==========================================
- Coverage 69.53% 69.47% -0.07%
==========================================
Files 9 9
Lines 3309 3315 +6
Branches 782 783 +1
==========================================
+ Hits 2301 2303 +2
- Misses 767 769 +2
- Partials 241 243 +2
Continue to review full report at Codecov.
|
I'm currently trying to find a PDF with an inline image so that the code at least runs once |
Ah, just found your comment again: from reportlab.pdfgen import canvas
c = canvas.Canvas("test.pdf")
c.drawInlineImage("test.png", 100, 100, 100, 100)
c.drawString(200, 100, "Test")
c.showPage()
c.save() |
Thank you so much for all the time you invested into this over so 5 years! 🙏 |
Security (SEC): - ContentStream_readInlineImage had potential infinite loop (#740) Bug fixes (BUG): - Fix merging encrypted files (#757) - CCITTFaxDecode decodeParms can be an ArrayObject (#756) Robustness improvements (ROBUST): - title sometimes None (#744) Documentation (DOC): - Adjust short description of the package Tests and Test setup (TST): - Rewrite JS tests from unittest to pytest (#746) - Increase Test coverage, mainly with filters (#756) - Add test for inline images (#758) Developer Experience Improvements (DEV): - Remove unused Travis-CI configuration (#747) - Show code coverage (#754, #755) - Add mutmut (#760) Miscellaneous: - STY: Closing file handles, explicit exports, ... (#743) All changes: 1.27.4...1.27.5
Recreated pull-request of the accidentally closed PR #331.
It fixes #329 by raising an exception when the stream ends and we haven't the end token for the inline image.
It also fixes #330 by using a more efficient parsing algorithm. For large inline images this change speeds up this method by many orders of magnitude:
find()
method to check for theE
the token. Only when the token is found it falls back to the normal algorithm that detects the end of the inline image.data
it usesBytesIO
to collect the output which support much faster appends.