File picker button labels show HTML entities for file names with special characters

未关闭 适合新手
#2,770 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
88/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
typescript
领域
frontend

调研方向

阅读 lib/filepicker-builder.ts 第 218–241 行附近的内容,这里会创建选择器按钮的默认标签,并查找相关的标签测试。检查 gettext 如何转义占位符值,以及标签如何作为文本渲染。更新标签,使包含撇号和与号的名称能原样显示,然后添加一个覆盖这些字符的测试。

由索引模型根据 Issue 内容生成。

描述

bug
Describe the bug

The file picker button labels that contain a file or folder name show HTML entities when the name contains characters like ', &, < or ", e.g. Choose Tom&#39;s folder or Copy to A &amp; B.

The labels are built with the gettext wrapper, which HTML-escapes placeholder values by default:

https://github.com/nextcloud-libraries/nextcloud-dialogs/blob/636c9a8ea2700380d4cd8d1b0b1d57d50850ab29/lib/filepicker-builder.ts#L218-L241

label = t('Choose {file}', { file: target })
// …
label: target ? t('Copy to {target}', { target }) : t('Copy'),
// …
label: target ? t('Move to {target}', { target }) : t('Move'),

The result is then rendered as plain button text (not as HTML), so the escaped entities are shown literally.

Originally reported in nextcloud/server#55191 for the "Set default folder for accepted shares" picker in the personal sharing settings, but it affects every picker using these default buttons (e.g. "Copy to …" / "Move to …" in the Files app).

To Reproduce

Found by code reading and the screenshot in nextcloud/server#55191.

  1. Create a folder named Tom's files.
  2. Open a file picker that uses the default buttons (e.g. "Move or copy" in Files) and select that folder.
  3. The button shows Copy to Tom&#39;s files.
Expected behavior

The labels show the plain name: either pass the placeholders unescaped (the labels are rendered as text, so no HTML escaping is needed there) or skip escaping for these button labels, with a test for a name containing ' and &.

主要语言
TypeScript
星标
19
派生
10
平均合并
17 小时 4 分钟
30 天内合并 PR
30

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

nextcloud-libraries/nextcloud-dialogs 的其他 Issue

查看 nextcloud-libraries/nextcloud-dialogs 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。