fix(updates): hide HTML comment markers in release notes

This commit is contained in:
t8y2 committed 2026-09-25 12:45:40 +08:00
1 parent b8274363b8
commit cb16b0f8be
2 files changed
+11 -1

No files matched your search

@@ -402,6 +402,15 @@ describe("UpdateDialog release notes safety", () => {
expect(document.body.querySelector("script, img")).toBeNull();
expect(Array.from(document.body.querySelectorAll("a")).every((anchor) => anchor.href.startsWith("https://"))).toBe(true);
});
it("hides HTML comments such as the CNB mirror marker instead of rendering them as text", async () => {
await mountDialog(0, { releaseNotes: "### 安装\n- 条目\n\n<!-- dbx-cnb-mirror -->\n> 国内下载:[CNB 镜像](https://cnb.cool/dbxio.com/dbx/-/releases)" });
await vi.waitFor(() => {
expect(document.body.querySelector('a[href^="https://cnb.cool"]')).not.toBeNull();
});
expect(document.body.textContent).not.toContain("dbx-cnb-mirror");
expect(document.body.textContent).not.toContain("<!--");
});
});
describe("UpdateDialog older versions", () => {
@@ -259,7 +259,8 @@ watch(
image: ({ text }) => escapeHtml(text),
},
});
renderedNotes.value = marked.parse(notes) as string;
// 已发布正文里的 HTML 注释(如 CNB 镜像幂等标记)在 GitHub 上不可见,转义前先剥离,避免以字面文本露出
renderedNotes.value = marked.parse(notes.replace(/<!--[\s\S]*?-->/g, "")) as string;
},
{ immediate: true },
);