Skip to content

feat(alias): support filename escaping - #2868

Open
qbisi wants to merge 2 commits into
OpenListTeam:mainfrom
qbisi:feat/alias-filename-escape
Open

feat(alias): support filename escaping#2868
qbisi wants to merge 2 commits into
OpenListTeam:mainfrom
qbisi:feat/alias-filename-escape

Conversation

@qbisi

@qbisi qbisi commented Jul 29, 2026

Copy link
Copy Markdown

该 feat 的一个直接 benefit 是用于 189cloud 文件名中 ' 和 U+4E73 字符的可逆替换:前者会被 189cloud 替换为不一致的 \',后者会导致文件无法下载;替换后字符分别变为 _x0027__x4E73__xHHHH_ 是一种在 XML、数据库以及电子表格解析中用于表示非法或无效字符的转义编码格式,其中 HHHH 代表该字符的四位十六进制 Unicode / UCS-2 编码。该格式能够兼容大部分网盘,是一种成熟的替换方案。

由于新增了 filename_escapefilename_escape_charsfilename_auto_rename 三个配置项,前端需要同步增加翻译。

Summary / 摘要

  • 为 Alias 存储增加默认关闭的 filename_escapefilename_auto_rename 开关,以及按行配置待转义字符串的 filename_escape_chars

  • 开启文件名转义后,在 Alias 读写边界匹配配置字符串,并仅将匹配字符串的首字符转换为 _xHHHH_ UTF-16 代码单元格式;同时保护原本存在的 _xHHHH_ 字面量。

  • 读取列表时保留后端真实路径,仅向用户展示还原后的名称;创建目录、重命名、上传和 URL 上传时向后端传递转义后的名称。

  • 开启 filename_auto_rename 后,Alias 在列出目录时自动将命中的后端既有文件或目录重命名为转义名称;迁移失败时保留原路径并继续列出目录。

  • 直接获取文件时兼容已存在的未转义文件名。

  • 改动仅限 Alias 驱动,不修改公共驱动接口或 internal 文件系统流程。

  • This PR has breaking changes.
    / 此 PR 包含破坏性变更。

  • This PR changes public API, config, storage format, or migration behavior.
    / 此 PR 修改了公开 API、配置、存储格式或迁移行为。

  • This PR requires corresponding changes in related repositories.
    / 此 PR 需要关联仓库同步修改。

Related Issues / 关联 Issue

Relates to #2792

Testing / 测试

  • go test ./...
  • go test ./drivers/alias ./internal/op ./internal/fs
  • git diff --check
  • Manual test / 手动测试

Checklist / 检查清单

  • I have read CONTRIBUTING.
    / 我已阅读 CONTRIBUTING。
  • I confirm this contribution follows the repository license, contribution policy, and code of conduct.
    / 我确认此贡献符合仓库许可证、贡献规范和行为准则。
  • I have formatted the changed code with gofmt, go fmt, or prettier where applicable.
    / 我已按适用情况格式化变更代码。
  • I have requested review from relevant maintainers or code owners where applicable.
    / 此 PR 已是 ready-for-review 状态,尚未额外请求维护者或 code owner 审查。

AI Disclosure / AI 使用声明

  • This PR includes AI-assisted content.
    / 此 PR 包含 AI 辅助内容。

Tools used / 使用工具:

  • Codex

Usage scope / 使用范围:

  • Code generation / 代码生成

  • Refactoring / 重构

  • Tests / 测试

  • Review assistance / 审查辅助

  • I have reviewed and validated all AI-assisted content included in this PR.
    / 已审查并验证此 PR 中包含的 AI 辅助内容。

  • I have ensured that all AI-assisted commits include Co-Authored-By attribution.
    / AI 辅助提交已包含 Co-authored-by 归属信息。

  • I can reproduce all AI-assisted content included in this PR without any AI tools.
    / 我可以在没有任何 AI 工具的情况下重现此 PR 中包含的所有 AI 辅助内容。

@qbisi
qbisi marked this pull request as ready for review July 29, 2026 21:39
qbisi and others added 2 commits July 30, 2026 08:16
- 增加默认关闭的文件名转义配置
- 在 Alias 读写边界转换 UTF-16 转义名称
- 保留后端真实路径并兼容未转义的已有文件

Co-authored-by: Codex <267193182+codex@users.noreply.github.com>
- add an opt-in setting to rename matching backend objects during directory listing
- preserve original paths when automatic renaming fails

Co-authored-by: Codex <267193182+codex@users.noreply.github.com>
@qbisi
qbisi force-pushed the feat/alias-filename-escape branch from af6b3c6 to 5798aff Compare July 30, 2026 01:14
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.

1 participant