Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:art: fix https://github.com/siyuan-note/siyuan/issues/7466

Vanessa6d6cd57b6f41
diff --git a/app/src/history/history.ts b/app/src/history/history.ts
index d1c2b5c3b5..b07eb8321b 100644
--- a/app/src/history/history.ts
+++ b/app/src/history/history.ts
@@ -7,7 +7,7 @@ import {Protyle} from "../protyle";
import {disabledProtyle, onGet} from "../protyle/util/onGet";
import * as dayjs from "dayjs";
import {fetchPost} from "../util/fetch";
-import {escapeHtml} from "../util/escape";
+import {escapeAttr, escapeHtml} from "../util/escape";
import {isMobile} from "../util/functions";
import {showDiff} from "./diff";
import {setStorageVal} from "../protyle/util/compatibility";
@@ -432,7 +432,7 @@ export const openHistory = () => {
iconElement.classList.add("b3-list-item__arrow--open");
let html = "";
response.data.items.forEach((docItem: { title: string, path: string }) => {
- html += `<li title="${escapeHtml(docItem.title)}" data-type="${typeElement.value === "2" ? "assets" : "doc"}" data-path="${docItem.path}" class="b3-list-item b3-list-item--hide-action" style="padding-left: 44px">
+ html += `<li title="${escapeAttr(docItem.title)}" data-type="${typeElement.value === "2" ? "assets" : "doc"}" data-path="${docItem.path}" class="b3-list-item b3-list-item--hide-action" style="padding-left: 44px">
<span class="b3-list-item__text">${escapeHtml(docItem.title)}</span>
<span class="fn__space"></span>
<span class="b3-list-item__action b3-tooltips b3-tooltips__w" data-type="rollback" aria-label="${window.siyuan.languages.rollback}">
diff --git a/app/src/util/escape.ts b/app/src/util/escape.ts
index dfb2618451..b1f15839b1 100644
--- a/app/src/util/escape.ts
+++ b/app/src/util/escape.ts
@@ -1,3 +1,7 @@
export const escapeHtml = (html: string) => {
return html.replace(/&/g, "&amp;").replace(/</g, "&lt;");
};
+
+export const escapeAttr = (html: string) => {
+ return html.replace(/"/g, "&quot;").replace(/'/g, "&apos;");
+};