fix(updates): hide HTML comment markers in release notes
This commit is contained in:
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(document.body.querySelector("script, img")).toBeNull();
|
||||||
expect(Array.from(document.body.querySelectorAll("a")).every((anchor) => anchor.href.startsWith("https://"))).toBe(true);
|
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", () => {
|
describe("UpdateDialog older versions", () => {
|
||||||
|
|||||||
@@ -259,7 +259,8 @@ watch(
|
|||||||
image: ({ text }) => escapeHtml(text),
|
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 },
|
{ immediate: true },
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in new issue
Block a user