Preview checker: entity names like `&constructor;` decode to function source

未关闭
#356 2 条评论 0 个 reaction 已指派 1 人 在 GitHub 查看

维护者通常 1 天内回复

@amitsinha-cell 已经在做这个了。

开始于 2026年10月31日。

评估

这个 Issue 还没有评估数据。

描述

bug

decodeEntities() in src/lib/meta-fetcher.ts looks names up with NAMED_ENTITIES[body], and NAMED_ENTITIES is a plain object, so names that exist on Object.prototype are found too. A page whose title has one of them shows function source in the preview checker:

parseMetaTags('<title>a &constructor; b</title>', 'https://example.com').title
// "a function Object() { [native code] } b"

&toString;, &hasOwnProperty; and &valueOf; do the same. Browsers leave an unknown name like &constructor; as it is.

What to do

  • Only decode names that are in NAMED_ENTITIES itself, for example with Object.hasOwn(NAMED_ENTITIES, body), or make it a null-prototype object or a Map.

Acceptance criteria

  • &constructor;, &toString;, &hasOwnProperty; and &valueOf; stay as they are, and every entity that decodes today still does
  • A test that fails on the current code
  • npm run check, npm run test and npm run build pass

Want to work on this? Comment below and I'll assign it to you. Please take one issue at a time, branch off dev, and open your PR against dev with Closes #NUM in the description.

主要语言
TypeScript
星标
8
派生
4
平均合并
8 小时 47 分钟
30 天内合并 PR
157

环境准备

从这里开始

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

codercops/ogcops 的其他 Issue

查看 codercops/ogcops 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

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