Escape the Binary field hint in the legacy content editor so an apostrophe doesn't break the field

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

维护者通常 2 天内回复

还没有人认领这个 Issue。

评估

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

调研方向

从dotCMS/src/main/webapp/html/portlet/ext/contentlet/field/edit_field.jsp中约第839行的hint赋值处开始,并与约第246行的字段变量 JSON 转义进行比较。检查此内联脚本中的值(包括字段值)是如何转义的,然后使用包含引号、反斜杠和换行符的 Binary 字段提示复现问题。完成标准是字段可以加载,输入的提示能正确显示,并且这些字符不再破坏脚本。

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

描述

OKR : Customer Support Team : Maintenance Type : Defect
Problem Statement

In the legacy (Dojo/JSP) content editor, a Binary field whose Hint contains an apostrophe (e.g. a user's computer) never finishes loading: the field area shows a spinner forever and no file can be uploaded.

The hint is written unescaped into a single-quoted JavaScript string in dotCMS/src/main/webapp/html/portlet/ext/contentlet/field/edit_field.jsp (~line 839):

hint: '<%=hint%>',

The apostrophe ends the string early, the inline script fails with Uncaught SyntaxError: Unexpected identifier 's', and the code that replaces the spinner with the dotcms-binary-field component never runs. A line break or backslash in the hint breaks it the same way. The field-variables JSON on line ~246 is already escaped with StringEscapeUtils.escapeJavaScript; the hint here is not.

Workaround: remove apostrophes and line breaks from the Binary field's hint.

Steps to Reproduce
  1. Create a content type with a Binary field.
  2. Set the Binary field's Hint to: Only include if a copy on a user's computer is useful.
  3. Open a new or existing contentlet of that type in the legacy content editor.
  4. Observe the Binary field spinner never resolves, and the browser console shows Uncaught SyntaxError: Unexpected identifier 's'.
Acceptance Criteria
  • A Binary field hint containing an apostrophe, double quote, backslash, or line break renders correctly and the field loads.
  • The hint text displays as entered.
  • Other values written into that inline script (e.g. the field value) are escaped for JavaScript the same way.
dotCMS Version

Current Evergreen release; present in main.

Severity

Low - Minor issue or cosmetic

Links
主要语言
Java
星标
972
派生
493
平均合并
2 天 12 小时
30 天内合并 PR
237

环境准备

在 Codespaces 中打开

在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。

从这里开始

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

dotCMS/core 的其他 Issue

查看 dotCMS/core 的全部 Issue

相似的 Issue

更多 Java Issue

把新 issue 发到你的邮箱

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