Skip to content

fix(id/web): saveFile reads dataset.filename, not decoded docId (#1494) - #3269

Merged
dezren39 merged 1 commit into
mainfrom
queue/4774-1494-savefile-filename
Nov 1, 2026
Merged

dezren39 merged 1 commit into
mainfrom
queue/4774-1494-savefile-filename

Conversation

@dezren39

@dezren39 dezren39 commented Nov 1, 2026 •

Copy link
Copy Markdown
Member

Fixes #1494 (triage task 1531, CONFIRMED-WITH-AMENDMENT).

Problem

saveFile read editorContainer.dataset.docId — the RAW filename (server emits data-doc-id html-escaped only, templates.rs) — and ran decodeURIComponent on it before its try block:

  • a filename with a valid %XX sequence (e.g. a%20b.md) saved under a different file's name (a b.md) — the server trusts the posted name, so this was a cross-file overwrite;
  • a filename with a bare % (e.g. 100%.md) threw URIError on every save and could never be saved.

Every other consumer (openEditor, tag refresh/panel, download, rename, copy) reads dataset.filename, which carries urlencoding::encode(name).

Change

  • New pkgs/id/web/src/save-filename.ts: resolveSaveFilename(dataset) resolves the save name from dataset.filename (keeping the decode, which is correct for that field). saveFile now uses it — no code in the save path decodes dataset.docId.
  • app.triggerSave fallback direct-save path: chained .catch(...) so a saveFile() rejection is handled (logs + save button shows "error!") instead of an unhandled rejection.
  • Regression test save-filename.test.ts (6 tests): dataset literals mirror templates.rs emission; a%20b.md and 100%.md save under their own exact names; docId is ignored entirely.

Server contract unchanged (templates.rs untouched); AutoSaveManager untouched.

Verification (laptop)

Queue task 4774 · lane E.


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need.

@dezren39
dezren39 requested a review from a team as a code owner November 1, 2026 00:47
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 1, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-01T00:55:42.844313Z 81871e1 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@coderabbitai

coderabbitai Bot commented Nov 1, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 27 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: ffdc2d03-b670-4f09-8215-b79504388a67
Commits

Reviewing files that changed from the base of the PR and between 2bc0bf9 and 81871e1.

Files selected for processing: 3
  • pkgs/id/web/src/main.ts
  • pkgs/id/web/src/save-filename.test.ts
  • pkgs/id/web/src/save-filename.ts
  • 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

@dezren39

dezren39 commented Nov 1, 2026

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Hooray!

Reviewed commit: 81871e1e4c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@dezren39
dezren39 merged commit ed3a285 into main Nov 1, 2026
2 of 3 checks passed
@dezren39
dezren39 deleted the queue/4774-1494-savefile-filename branch November 1, 2026 01:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant