fix(execd): encode non-ASCII filenames in Content-Disposition header#472
Merged
Pangjiping merged 1 commit intoalibaba:mainfrom Mar 18, 2026
Merged
fix(execd): encode non-ASCII filenames in Content-Disposition header#472Pangjiping merged 1 commit intoalibaba:mainfrom
Pangjiping merged 1 commit intoalibaba:mainfrom
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d98abff5f4
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
Use RFC 6266 and RFC 5987 encoding for filenames containing non-ASCII characters (e.g., Chinese, Japanese) in file download responses. - Add formatContentDisposition function to properly encode filenames - Add unit tests for ASCII and non-ASCII filename scenarios
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Use RFC 6266 and RFC 5987 encoding for filenames containing non-ASCII characters (e.g., Chinese, Japanese) in file download responses.
Summary
What: 修复
FilesystemController.DownloadFile方法中Content-Disposition响应头对非ASCII文件名(如中文、日文)编码不正确的问题。Why: 原代码直接拼接文件名到 Header 中,当文件名包含非ASCII字符时会导致客户端(浏览器)无法正确解析文件名,出现乱码或下载失败。现按照 RFC 6266 和 RFC 5987 规范对非ASCII文件名进行 URL 编码,确保跨浏览器兼容性。
Changes:
components/execd/pkg/web/controller/filesystem_download.go: 新增formatContentDisposition函数components/execd/pkg/web/controller/filesystem_test.go: 新增单元测试Testing
Unit tests: 新增
TestFormatContentDisposition测试用例,覆盖以下场景:test.txt)测试文件.txt)テスト.txt)file with spaces.txt)report-报告.pdf)所有测试均通过。
Breaking Changes
此修改仅为内部实现优化,API 行为保持向后兼容。
Checklist
Security: 无安全影响,仅涉及响应头编码格式。
Backward Compatibility: 完全向后兼容,纯 ASCII 文件名行为不变,非 ASCII 文件名获得正确编码。