Skip to content

fix(execd): encode non-ASCII filenames in Content-Disposition header#472

Merged
Pangjiping merged 1 commit intoalibaba:mainfrom
csdbianhua:main
Mar 18, 2026
Merged

fix(execd): encode non-ASCII filenames in Content-Disposition header#472
Pangjiping merged 1 commit intoalibaba:mainfrom
csdbianhua:main

Conversation

@csdbianhua
Copy link
Contributor

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

Summary

  • What is changing and why?

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

  • Not run (explain why)
  • Unit tests
  • Integration tests
  • e2e / manual verification

Unit tests: 新增 TestFormatContentDisposition 测试用例,覆盖以下场景:

  • 纯 ASCII 文件名(test.txt
  • 中文文件名(测试文件.txt
  • 日文文件名(テスト.txt
  • 包含空格的文件名(file with spaces.txt
  • 混合 ASCII 和非 ASCII 文件名(report-报告.pdf

所有测试均通过。

Breaking Changes

  • None
  • Yes (describe impact and migration path)

此修改仅为内部实现优化,API 行为保持向后兼容。

Checklist

  • Linked Issue or clearly described motivation
  • Added/updated docs (if needed)
  • Added/updated tests (if needed)
  • Security impact considered
  • Backward compatibility considered

Security: 无安全影响,仅涉及响应头编码格式。

Backward Compatibility: 完全向后兼容,纯 ASCII 文件名行为不变,非 ASCII 文件名获得正确编码。

@CLAassistant
Copy link

CLAassistant commented Mar 18, 2026

CLA assistant check
All committers have signed the CLA.

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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
Copy link
Collaborator

@Pangjiping Pangjiping left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Pangjiping Pangjiping merged commit e7f772f into alibaba:main Mar 18, 2026
11 of 13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working component/execd

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants