Repository navigation
fix(pptx): limit the decompressed size of PPTX archive members - #5113
Conversation
|
✅ DCO Check Passed Thanks @hktitof, all your commits are properly signed off. 🎉 |
Merge Protections🟢 Merge protection satisfied — ready to merge. Show 1 satisfied protection🟢 Enforce conventional commitMake sure that we follow https://www.conventionalcommits.org/en/v1.0.0/
|
AI triage (advisory)Checked commit The PR adds decompressed-size limits for PPTX archives. CI safety: no concern found. A maintainer must still approve CI. 2 related pull request(s) in the same code
The |
There was a problem hiding this comment.
AI first review (advisory): no blocker found
This review covers the full diff at 0fec429e5a. It read the code and did not run it.
I found no defect. docling/backend/mspowerpoint_backend.py now checks the archive limits the same way docling/backend/msexcel_backend.py does, and the new options match the Word and Excel options. The check runs before Presentation(), rewinds a BytesIO stream after the check, and re-raises ArchiveLimitError before the generic DocumentLoadError wrapper. The parametrized PPTX tests in tests/test_backend_archive_limits.py test the real defect for both path and stream input. They use a real sample deck, an inflated member, and an assertion on the rejection cause.
A maintainer makes the merge decision. This review never approves the pull request.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
A PPTX package is a ZIP archive. python-pptx decompresses its members while it loads them, without a check of the declared sizes, so a small file can decompress to a very large size. DOCX and XLSX packages already have this check (see docling-project#4977). A PPTX file now fails to load with ArchiveLimitError, before python-pptx reads any member, when one member, the whole package or the member count exceeds the limit. MsPowerpointBackendOptions gets max_file_bytes (128 MiB), max_total_bytes (512 MiB) and max_member_count (10,000). Signed-off-by: Abdel <62770500+hktitof@users.noreply.github.com>
There was a problem hiding this comment.
AI first review (advisory): no blocker found
This review covers the full diff at 16def335ac. It read the code and did not run it.
I found no defect that blocks the merge. The check in docling/backend/mspowerpoint_backend.py runs before Presentation(). It uses the shared check_archive_limits helper, the same as the Word backend. ArchiveLimitError is re-raised before the generic except Exception can wrap it. The new options and their defaults match the DOCX/XLSX options. The PPTX cases in tests/test_backend_archive_limits.py reuse the existing parametrized tests, including the converter-level test.
A maintainer makes the merge decision. This review never approves the pull request.
|
Thanks for the review and merge @dolfim-ibm, glad this fix is in now, cheers! |
what this fixes
a .pptx file is a ZIP archive, same as docx and xlsx, python-pptx decompresses the package members while it loads them and there was no check of the declared sizes for PPTX, so a small .pptx can decompress to a very large size in memory
#4977 added that check for docx, xlsx and epub, it did not cover PPTX
what changed
MsPowerpointBackendOptionsgetsmax_file_bytes(128 MiB),max_total_bytes(512 MiB) andmax_member_count(10,000), the same defaults as the word and excel backendsMsPowerpointDocumentBackendcallscheck_archive_limits()beforePresentation(), so a file over a limit fails withArchiveLimitError(aDocumentLoadError) and no member is readreview evidence
i drove the real converter (
DocumentConverter.convert) with a real 78 KB .pptx whoseppt/slides/slide1.xmldeclares 32,520,093 bytes (about 31 MiB) of decompressed dataArchiveLimitError, 0.2 MiB peakbefore this change
MsPowerpointBackendOptions(max_file_bytes=...)was accepted and then ignored, so the limit looked like it worked and did nothingtest and check commands i ran
Checklist:
note
check-collisionreports file overlap only, with 21 open PRs (#5085 #5082 #5063 #5057 #5017 #5005 #4880 #4844 #4815 #4781 #4752 #4716 #4689 #4546 #4443 #4148 #4144 #3978 #3891 #3803 #3791), none of them is about archive size limits, most of them only touch the docs, the overlap is mechanical