Skip to content

M14: preserve existing PDF suffixes in web exports - #6817

Merged
FredApps merged 4 commits into
storytold:mainfrom
MMexicann:patch-45
Nov 15, 2026
Merged

FredApps merged 4 commits into
storytold:mainfrom
MMexicann:patch-45

Conversation

@MMexicann

@MMexicann MMexicann commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

An explicit web file.exportPdf request for Report.PDF currently downloads Report.PDF.pdf: the download branch recognizes only a lowercase .pdf suffix, although the existing I/O dispatcher accepts extension case. Make that suffix check ASCII case-insensitive while preserving the exact requested filename.

Add a WordApp regression with a download callback that checks the delivered name and PDF header for lowercase, uppercase, mixed-case Unicode and missing-suffix inputs.

Validation: the exact filename expression passes all 3 focused Rust probe cases with this change; the original expression fails the mixed/uppercase group (2 passed, 1 failed). Complete modified files pass rustfmt. Independent source/API review, including the current download callback signature, found no issue; both browser baselines match the reviewed source. Full WordApp/UI/wasm tests and the workspace gate did not run locally; hosted checks on head 3e776e4c7d6fb901d2439738b9ced1513ec2c426 remain pending.

Searched issues and open/closed PRs for file.exportPdf, extensions and duplicate PDF suffixes. Closed #212 covers the edited indicator after downloads; the existing Save As work covers separate chooser behavior.

Summary by CodeRabbit

  • Bug Fixes
    • Web PDF exports now preserve an existing .pdf extension regardless of capitalization and add the extension when it’s missing.
  • Tests
    • Added checks for PDF download names across filename edge cases and for exported files containing PDF content.

Recognize an existing PDF extension without changing its case or the requested filename.
Assert exact delivered filenames and PDF bytes for lowercase, uppercase, mixed-case Unicode and missing suffixes.
@coderabbitai

coderabbitai Bot commented Nov 15, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The web PDF export path checks whether a filename ends in .pdf without regard to ASCII letter case. Tests cover suffix variants, filenames without the suffix, lookalike endings, and downloaded PDF data.

Changes: Web PDF export

Layer / File(s) Summary
PDF suffix handling and coverage
crates/ui-egui/src/app/commands.rs, crates/ui-egui/src/file_dialogs/tests.rs
The export path appends .pdf only when the filename does not already end with that suffix, ignoring ASCII letter case. Tests check expected download names and PDF data.

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

Change: Bug fix

Suggested reviewers: aiongg

Merge Risk: Minimal · up to 5f228

Web PDF export now keeps an existing .pdf suffix in any ASCII letter case instead of appending a second one. The change is small and covered by a regression test, so the risk of merging is minimal pending normal CI.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names the main change: web PDF export now keeps an existing .pdf suffix instead of appending another one. The raw summary and objectives both describe case-insensitive suffix recognition for…
Linked Issues check Passed The only directly linked issue, #212, is closed and completed. Under the assessment rules it supplies background only, so no active coding requirements apply. The PR changes the web file.exportPdf suf…
Out of Scope Changes check Passed The head version of crates/ui-egui/src/app/commands.rs confirms the change is limited to the web download suffix check for file.exportPdf. The check does not alter the filename or the download policy …
Full details: Title check

Explanation

The title names the main change: web PDF export now keeps an existing .pdf suffix instead of appending another one. The raw summary and objectives both describe case-insensitive suffix recognition for file.exportPdf in web downloads, with the requested filename preserved. The title is specific and the 'M14' prefix is a milestone tag that does not hurt clarity.

Full details: Linked Issues check

Explanation

The only directly linked issue, #212, is closed and completed. Under the assessment rules it supplies background only, so no active coding requirements apply. The PR changes the web file.exportPdf suffix check, which is separate from #212's Edited-indicator work. The reviewed head is 5f228a0. The file read of crates/ui-egui/src/app/commands.rs at head shows the new check in WordApp::execute: name.as_bytes().last_chunk::<4>().is_some_and(|suffix| suffix.eq_ignore_ascii_case(b".pdf")), followed by format!("{name}.pdf") only when id == "file.exportPdf" and no suffix matches. This matches the PR objective. Names shorter than four bytes return None and get .pdf appended. Multibyte names cannot match because the four ASCII bytes must equal .pdf, so no UTF-8 boundary issue arises. The filename is kept as requested. The whole-PR diff tool could not return text (changed blobs missing), so the exact diff hunks were not confirmed; the verdict rests on the file read at head.

Full details: Out of Scope Changes check

Explanation

The head version of crates/ui-egui/src/app/commands.rs confirms the change is limited to the web download suffix check for file.exportPdf. The check does not alter the filename or the download policy for other commands. The raw summary reports a companion test in crates/ui-egui/src/file_dialogs/tests.rs covering ASCII case variants and nonmatching endings; this test is supporting material for the objective. The test-file diff could not be read (changed blobs missing), so its contents rest on the supplied summary and PR description. No unrelated change was identified in the evidence available.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 3e776e4 and 5f228a0.

Files selected for processing: 2

  • crates/ui-egui/src/app/commands.rs
  • crates/ui-egui/src/file_dialogs/tests.rs

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

@Pipeliner

Copy link
Copy Markdown

does this handle all filenames, potentially hostile? is there a way to express this logic more robustly?

Added additional test cases for PDF file name handling in file dialogs.

@FredApps FredApps left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Reviewed 5f228a0. The bounded four-byte suffix comparison preserves the requested filename and is safe for short and multibyte UTF-8 names. It matches the existing I/O extension dispatch, which normalizes ASCII case before selecting the PDF writer. The WordApp callback regression checks both the actual delivered filename and PDF signature across mixed-case, Unicode, short and misleading-suffix cases. No blocking issue found. Exact-head CI, all three printing platforms and Sonar scan passed; coverage skipped. I did not run an additional local build.

@FredApps
FredApps merged commit 84026f9 into storytold:main Nov 15, 2026
9 checks passed
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.

3 participants