Skip to content

Find zip entries stored with backslash separators in pptx packages - #1406

Merged
h-a-n-a-s-h-i merged 1 commit into
storytold:mainfrom
Silvertree2010:fix/h2720-zip-entries-named-with-backslash
Oct 30, 2026
Merged

h-a-n-a-s-h-i merged 1 commit into
storytold:mainfrom
Silvertree2010:fix/h2720-zip-entries-named-with-backslash

Conversation

@Silvertree2010

@Silvertree2010 Silvertree2010 commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Found while testing crates/pptx/src/opc.rs:77-82 (Package::open_within), lookup in Package::get via norm at :258 (no existing issue): Zip entries named with backslash separators are never found when a .pptx is opened.

Cause

Package::open_within keyed parts by name.to_ascii_lowercase(), but Package::get looks them up with norm(), which also turns \ into /. Entries such as ppt\slides\slide1.xml were stored under the backslash name and could never be found.

Fix

Parts are now keyed with norm(&name), the same function the lookup uses. norm also lowercases ASCII, so case-insensitive lookup still works. The regression test opc::tests::backslash_zip_entry_names_are_found uses the mixed-case backslash entry PPT\Slides\Slide1.xml. It fails without the fix and passes with it.

Verified

  • Regression test opc::tests::backslash_zip_entry_names_are_found: fails on main without the fix and passes with it (cargo test -p deckcraft-pptx --lib backslash_zip_entry_names_are_found).
  • cargo xtask ci passes except tests::east_asian_vertical_text_stands_ideographs_upright, which also fails on main without this change.

Not changed

The original entry name is still stored and returned as before. How two entries that normalise to the same key collide is unchanged: the later entry still replaces the earlier one, as it did for case-only collisions. Verify with cargo test -p deckcraft-pptx --lib backslash_zip_entry_names_are_found.

🤖 Generated with AI by ApolloOffice, see the Co-Authored-By trailers for the models

Summary by CodeRabbit

  • Bug Fixes
    • Package contents can now be found when ZIP entry names use backslashes or mixed capitalization, even when requested with lowercase, slash-separated paths. This improves compatibility when opening packages created with differing path conventions.

Found while testing crates/pptx/src/opc.rs:77-82 (Package::open_within), lookup in Package::get via norm at :258

Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between aaf6c1c and 939bd12.

Files selected for processing: 1
  • crates/pptx/src/opc.rs

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.

Walkthrough

Package::open_within now normalizes ZIP entry names by converting backslashes to slashes and lowercasing them. A test checks retrieval of a mixed-case, backslash-separated entry using a lowercase, slash-separated path.

Changes: ZIP entry lookup

Layer / File(s) Summary
Normalize and test entry lookup
crates/pptx/src/opc.rs
ZIP entry names use norm for separator and case normalization. A test verifies lookup of PPT\Slides\Slide1.xml as ppt/slides/slide1.xml.

Priority: Normal

Estimated code review effort: 2 (Simple) | ~8 minutes

Change: Bug fix

Suggested reviewers: echelon

Merge Risk: Minimal · up to 939bd

The PR aligns ZIP entry indexing with lookup normalization and adds focused regression coverage.

Security architecture risk: Low · up to 939bd

The change is confined to presentation-package lookup and preserves existing decompression and XML-size controls. It also makes slash and backslash variants collide, with the later accepted entry winning. No security-control bypass was established, but the policy for ambiguous packages is not explicitly covered.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — A supplier of an imported archive controls entry names, contents and ordering, and can therefore influence which separator-alias entry is selected within that package. The inspected change adds no new endpoint or authority; its direct effect is package-local content selection through existing import APIs.

Trust Boundaries and Controls

  • observed — Existing entry-count, per-part, cumulative-byte and inflate-work controls precede index insertion. Inflated bytes are charged even when discarded, and XML lookup retains its separate size limit. Normalizing the insertion key does not remove these controls.
  • observed — Inspected chart-preservation paths retain normalized folder and dot-segment validation, while the writer assigns generated names to preserved parts. Expanded reader matching did not demonstrate a bypass of those output-path controls.

Resilience and Maintainability Implications

  • observed — The index is built locally and exposed only on constructor return. Unreadable or oversized entries are skipped, and work-budget exhaustion returns the accepted subset under existing behavior. Replacement occurs only after an entry has passed reading and size checks, so a rejected alias does not overwrite an accepted part.
Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 1 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: locating ZIP entries that use backslash separators in PPTX packages.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

@Harrison-Booth

Copy link
Copy Markdown
Contributor

Review notes (read the diff, ran tests on Linux).

Ran cargo test -p deckcraft-pptx opc on this branch (8 pass, including the new backslash_zip_entry_names_are_found) and cargo fmt --check (clean).

The change keys parts by norm(&name) (trim leading /, \ to /, lowercase), which is the same normalisation Package::get and sidecar_part already use, so lookups and storage agree. One edge: if a zip holds both a\b.xml and a/b.xml, they now collide and the later entry wins; previously they were different keys. Unlikely in real files.

Not checked: whether PowerPoint itself opens a package with backslash entry names (I did not build such a file for PowerPoint), and no real-world file with this problem was available to try.

@Harrison-Booth

Copy link
Copy Markdown
Contributor

Checked with real PowerPoint (Microsoft Office 16, on Windows) and a scratch build of crates/pptx.

What ran:

  • Saved a one-slide deck from PowerPoint COM, then rewrote the zip so every entry except [Content_Types].xml uses backslash separators (ppt\presentation.xml, ppt\slides\slide1.xml, _rels\.rels, ...).
  • Opened both the original and the rewritten file in PowerPoint through COM: both open with 1 slide and the same title.
  • Ran both through deckcraft_pptx::import:
    • main: the original imports with 1 slide, the backslash copy fails with not a PPTX file: missing or unreadable ppt/presentation.xml.
    • This PR (939bd128): both import with 1 slide and the same title.

So on main the whole file is rejected, not only one slide, and with this change it opens as PowerPoint does.

Not checked: the PR's unit test and the app UI.

@h-a-n-a-s-h-i
h-a-n-a-s-h-i merged commit 939bd12 into storytold:main Oct 30, 2026
7 checks passed
h-a-n-a-s-h-i pushed a commit that referenced this pull request Oct 30, 2026
Find zip entries stored with backslash separators in pptx packages
@echelon

echelon commented Oct 30, 2026

Copy link
Copy Markdown
Member

Landed on main, thank you @Silvertree2010 for the contribution! If you haven't already, come join us on Discord: https://discord.gg/artcraft

@echelon

echelon commented Oct 30, 2026

Copy link
Copy Markdown
Member

Note on what I changed before landing: the stored original name also uses /, so original_name() never hands a backslash path to the media/chart readers.

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.

4 participants