Skip to content

fix: support non-ASCII filenames in file download headers (RFC 5987)#348

Open
vincentmaria wants to merge 1 commit into
LogicLabs-OU:mainfrom
vincentmaria:main
Open

fix: support non-ASCII filenames in file download headers (RFC 5987)#348
vincentmaria wants to merge 1 commit into
LogicLabs-OU:mainfrom
vincentmaria:main

Conversation

@vincentmaria
Copy link
Copy Markdown

Problem

When downloading attachments or EML files with non-ASCII characters in their filename (e.g. German umlauts like ä, ö, ü), the backend throws a Node.js ERR_INVALID_CHAR error and returns HTTP 500:

Error downloading file: TypeError [ERR_INVALID_CHAR]: Invalid character in header content ["Content-Disposition"]                                                                                                     
     at ServerResponse.setHeader (node:_http_outgoing:703:3)                                                                                                                                                           
     at downloadFile (/app/packages/backend/dist/api/controllers/storage.controller.js:70:17)    

This affects all file downloads via GET /api/v1/storage/download where the filename contains characters outside the ASCII range.

Closes #182

Root Cause

storage.controller.ts sets the header as:

Content-Disposition: attachment; filename="Geschäftsbericht.pdf"

Node.js rejects non-ASCII bytes in HTTP headers.

Fix

Encode the filename using RFC 5987 (filename*=UTF-8''...), which is supported by all modern browsers (Firefox 5+, Chrome 13+, Safari 6+):

Content-Disposition: attachment; filename*=UTF-8''Gesch%C3%A4ftsbericht.pdf

Changes

  • packages/backend/src/api/controllers/storage.controller.ts:
    2-line change

Prior Work

A nearly identical fix was independently implemented by @prinsss in their fork (commit prinsss/OpenArchiver@021f34f, October 2025) but was never submitted as a PR to this repository.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 7, 2026

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@prinsss
Copy link
Copy Markdown

prinsss commented Apr 7, 2026

Thanks for mentioning! :)

That commit is actually included in PR #181 which is currently under review. I was too lazy to submit a new separated PR back at that time. Sorry for the confusion. 😂

@vincentmaria
Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA

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.

Error downloading file: TypeError [ERR_INVALID_CHAR]: Invalid character in header content ["Content-Disposition"]

2 participants