This repository was archived by the owner on Feb 27, 2026. It is now read-only.
fix(server): Remove RFC 2616 separator chars from Content-Disposition filename#291
Merged
danielalves96 merged 2 commits intonextfrom Oct 20, 2025
Merged
Conversation
… filename Filter out HTTP token separator characters (including parentheses, brackets, commas, etc.) from the ASCII-safe portion of the Content-Disposition header to prevent S3 providers like Backblaze B2 from rejecting the header. The full filename with special characters is still preserved in the filename*=UTF-8 parameter. Co-authored-by: danielalves96 <62755605+danielalves96@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix file download and preview issues for special characters
fix(server): Remove RFC 2616 separator chars from Content-Disposition filename
Oct 9, 2025
anthony0030
pushed a commit
to anthony0030/Palmr
that referenced
this pull request
Jan 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
File downloads and previews were failing on S3-compatible storage providers (particularly Backblaze B2) when filenames contained special characters like parentheses, brackets, or commas.
For example, a file named
privacypack (2).pngwould result in this error from Backblaze B2:Root Cause
The
encodeFilenameForHeaderfunction in boths3-storage.provider.tsandfilesystem/controller.tswas generating Content-Disposition headers that violated RFC 2616 HTTP token specifications.The function was creating ASCII-safe filenames by filtering characters to the range 32-126, which includes many characters that are not valid in HTTP tokens according to RFC 2616:
()[],;@According to RFC 2616, tokens can only contain:
A-Z,a-z,0-9!,#,$,%,&,',*,+,-,.,^,_,`,|,~Solution
Added a new
isTokenChar()helper method that properly validates characters according to RFC 2616 token rules. This method filters out all separator characters (()<>@,;:\"/[]?={} \t) from the ASCII-safe portion of the Content-Disposition header.The fix ensures:
filenameparameter only contains valid RFC 2616 token charactersfilename*=UTF-8''...parameterExample
Before:
❌ Rejected by S3 providers because
(and)are not valid token charactersAfter:
✅ Accepted by all S3 providers
privacypack2.pngprivacypack%20(2).pngTesting
Verified with multiple test cases:
privacypack (2).png→privacypack2.pngdocument[1].pdf→document1.pdffile@email.com.txt→fileemail.com.txtfile,with,commas.txt→filewithcommas.txtmy-file.zip→my-file.zip(no change needed)Impact
Fixes #288
Original prompt
Fixes #262
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.