Skip to content

fix(local): drop a backslash from a revised copy's download name - #2443

Open
MohammadHijjawi97 wants to merge 1 commit into
MODSetter:devfrom
MohammadHijjawi97:fix/revised-copy-download-backslash
Open

MohammadHijjawi97 wants to merge 1 commit into
MODSetter:devfrom
MohammadHijjawi97:fix/revised-copy-download-backslash

Conversation

@MohammadHijjawi97

@MohammadHijjawi97 MohammadHijjawi97 commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

What

download_name in modules/artifacts/revised_copies/downloads.py now drops a backslash from a revised copy's saved name, as it already drops <>:"/|?* and control characters. The character class read \| as an escaped pipe, so the backslash was never in it; it is now \|, as in agent/thread_folder/mirror_path.py.

Why

docs/architecture/studio.md says the name has "the characters no file system takes dropped", but a backslash got through. A source whose name has one, which macOS and Linux allow (and the Docker build runs on Linux), kept it in the download name, and so did a ?suffix= holding one. Windows reads it as a folder separator.

Before (source-name case with POSIX path handling):

download_name("Q3\Q4.docx", 1, "revised")  ->  'Q3\Q4 (revised v1).docx'
download_name("Plan.docx", 2, "re\vised")  ->  'Plan (re\vised v2).docx'

After:

'Q3Q4 (revised v1).docx'
'Plan (revised v2).docx'

How to test

cd surfsense_local/backend
uv run pytest tests/unit/artifacts/revised_copies/test_download_names.py

Two new tests: the suffix case runs everywhere; the source-name case is skipped on Windows, whose paths split at a backslash. Without the fix, the suffix test fails with 'Plan (re\vised v2).docx' != 'Plan (revised v2).docx'. uv run ruff check . passes.

Summary by CodeRabbit

  • Bug Fixes
    • Fixed downloaded file names that contain backslashes by removing those characters, including from suffixes and source names on non-Windows systems. This helps ensure file names are handled consistently across platforms.

The character class in downloads.py read `\|` as an escaped pipe, so a
backslash was never removed. A source named on macOS or Linux, or a
suffix, could put one in the saved name, which Windows cannot save.
@vercel

vercel Bot commented Nov 18, 2026

Copy link
Copy Markdown

@MohammadHijjawi97 is attempting to deploy a commit to the Rohan Verma's projects Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitai Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The download filename sanitizer now removes backslashes. Tests cover backslashes in suffixes and source names on non-Windows systems.

Changes: Filename sanitization

Layer / File(s) Summary
Sanitize backslashes in download names
surfsense_local/backend/modules/artifacts/revised_copies/downloads.py, surfsense_local/backend/tests/unit/artifacts/revised_copies/test_download_names.py
The sanitizer removes backslashes. Tests check suffixes and, on non-Windows systems, source names.

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

Change: Bug fix

Merge Risk: Minimal · up to f5f59

This change makes revised-copy download names drop backslashes, as intended. No concrete merge-blocking risk was found, and tests cover both the suffix and source-name cases.

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 "fix(local): drop a backslash from a revised copy's download name" matches the main change. The sanitizer in downloads.py now removes backslashes from revised-copy download names, and the te…
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.
Full details: Title check

Explanation

The title "fix(local): drop a backslash from a revised copy's download name" matches the main change. The sanitizer in downloads.py now removes backslashes from revised-copy download names, and the tests cover backslashes in the suffix and, on non-Windows systems, in the source name. The title is specific and describes the primary change. It omits the suffix aspect, which is acceptable because the title does not need to cover every detail.

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 7e03b16 and f5f593a.

Files selected for processing: 2

  • surfsense_local/backend/modules/artifacts/revised_copies/downloads.py
  • surfsense_local/backend/tests/unit/artifacts/revised_copies/test_download_names.py

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

This branch has not been deployed

No deployments
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.

1 participant