Preview checker: `<meta>` tags inside a `<script>` string override the real ones
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 84/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- typescript
- 领域
- backend
调研方向
从 src/lib/meta-fetcher.ts 中的 parseMetaTags() 及其解析器测试开始。检查注释是如何被剥离的,然后覆盖带属性且大小写混合的 script 元素,包括 JSON-LD 和多个 script。添加一个回归测试,证明 script 内的标签不会影响 title、meta 或 canonical 结果,而 script 外的标签仍按原样解析。
由索引模型根据 Issue 内容生成。
描述
parseMetaTags() in src/lib/meta-fetcher.ts strips HTML comments before it looks for tags (#389), but it still reads tags out of <script> contents. In HTML a script's contents are plain text, so a browser never sees tags written inside a JavaScript string, but the checker does, and a later meta tag overwrites an earlier one:
parseMetaTags(`
<meta property="og:title" content="Pricing | Acme">
<script>const share = '<meta property="og:title" content="Untitled">';</script>
`, 'https://example.com').ogTitle
// "Untitled"
It goes the other way for the tags where the first one wins: a <title> or <link rel="canonical"> inside a script before the real ones is picked instead, so a page gets Draft and https://acme.dev/draft instead of Pricing | Acme and https://acme.dev/pricing.
What to do
- Remove
<script>elements with their contents (any attributes, any case) right after the comments are stripped, so everything below works on HTML without them. A non-greedy match up to the first</script>is enough, since that's where HTML ends a script too.
Acceptance criteria
- A
<title>,<meta>or<link>inside a<script>, before or after the real tag, never changes the result - Tags outside scripts parse the same as today, including a page with several scripts and a
<script type="application/ld+json"> - A test that fails on the current code
-
npm run check,npm run testandnpm run buildpass
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 小时 44 分钟
- 30 天内合并 PR
- 159
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
codercops/ogcops 的其他 Issue
-
Preview checker: a `<title>` written over several lines keeps its line break and indentation可能已有人在做 @bhushan4work 于 1 天前认领。 未关闭bug good first issue
难度 2/5 1-3 小时 新手友好度 84/100
codercops/ogcops#393 · 1 条评论 · 已指派 1 人 ·
维护者通常 1 天内回复
-
[Bug] “Copy Recommended Meta Tags” generates an unusable placeholder image URL可能重新可做 @CreatorguyS 于 7 天前认领,目前没有进行中的 PR。 未关闭bug enhancement
难度 2/5 1-3 小时 新手友好度 72/100
codercops/ogcops#378 · 4 条评论 ·
维护者通常 1 天内回复
-
bug good first issue
难度 3/5 1-2 天 新手友好度 78/100
维护者通常 1 天内回复
-
Add the Do and Don't tutorial template (`tutorial-do-dont`)可能已有人在做 @Ravindar-Amogh-Gummadavelly 于 7 天前认领。 未关闭good first issue templates
codercops/ogcops#355 · 2 条评论 · 已指派 1 人 ·
维护者通常 1 天内回复
-
enhancement
难度 5/5 一周以上 新手友好度 30/100
codercops/ogcops#341 · 2 条评论 ·
维护者通常 1 天内回复
相似的 Issue
-
难度 1/5 1-3 小时 新手友好度 86/100
ranxianglei/billion-context#5893 ·
维护者通常 1 天内回复
-
stringify escapes leading digits in pseudo-class arguments (:nth-child(1) becomes :nth-child(\31 ))未关闭
难度 2/5 1-3 小时 新手友好度 83/100
维护者通常 1 天内回复
-
enhancement security severity:low
难度 2/5 1-3 小时 新手友好度 83/100
Battle-Cattle/BCUK-Bot-4#959 ·
维护者通常 1 天内回复
-
[Bug]: Claude account rows no longer show the email (since #8055), so "Account 1, 2, 3" cannot be told apart可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭account-pool bug gui
难度 2/5 1-3 小时 新手友好度 76/100
lidge-jun/opencodex#8286 · 2 条评论 · 1 个 reaction ·
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 72/100
维护者通常 1 天内回复