Skip to content

🐛(backend) sanitize slash in template-created filenames#641

Open
neilcroft wants to merge 1 commit intosuitenumerique:mainfrom
neilcroft:fix/626-wopi-special-chars-filename
Open

🐛(backend) sanitize slash in template-created filenames#641
neilcroft wants to merge 1 commit intosuitenumerique:mainfrom
neilcroft:fix/626-wopi-special-chars-filename

Conversation

@neilcroft
Copy link
Copy Markdown
Contributor

Purpose

Titles containing '/' (e.g. "30/03/30 - liste à faire") produced a file_key with spurious path separators, crashing WOPI on open.

Closes #626

Proposal

Extract format_template_filename() to replace '/' with '-' when building the filename from a template title.

Alternatives considered

Applying sanitize_filename() to template filenames

This existing function converts to ASCII, replaces spaces with underscores, and strips special characters. It would fix the / issue but also mangle titles like "café résumé" into "cafe_resume", which diverges from what the user typed. Since the frontend displays title (not filename), the name would look fine in Drive but appear mangled in Collabora's editor (BaseFileName).

Aligning all filename paths to only replace /

I explored replacing sanitize_filename() with the minimal / -> - replacement in the rename task and update validation as well (not just template creation). This would make filenames consistent across all paths (template, rename, WOPI) and preserve unicode/accents everywhere. I decided against it for now as it changes behavior on existing rename and update paths, and S3 keys would start containing characters they didn't before. The current fix is scoped to the template creation path where the bug occurs.

Titles containing '/' (e.g. "30/03/30 - liste à faire") produced
a file_key with spurious path separators, crashing WOPI on open.

Extract `format_template_filename()` to replace '/' with '-' when
building the filename from a template title.

Closes suitenumerique#626
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud bot commented Apr 3, 2026

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.

WOPI crash when opening files with special chars

1 participant