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/11489

Vanessa17e77274fa66
diff --git a/app/src/block/popover.ts b/app/src/block/popover.ts
index 7249f2d819..1be063d911 100644
--- a/app/src/block/popover.ts
+++ b/app/src/block/popover.ts
@@ -32,13 +32,13 @@ export const initBlockPopover = (app: App) => {
} else {
if (aElement.firstElementChild?.getAttribute("data-type") === "url") {
if (aElement.firstElementChild.textContent.indexOf("...") > -1) {
- tip = aElement.firstElementChild.getAttribute("data-href");
+ tip = Lute.EscapeHTMLStr(aElement.firstElementChild.getAttribute("data-href"));
}
}
if (!tip && aElement.dataset.wrap !== "true" && event.target.dataset.type !== "block-more" && !hasClosestByClassName(event.target, "block__icon")) {
aElement.style.overflow = "auto";
if (aElement.scrollWidth > aElement.clientWidth + 2) {
- tip = getCellText(aElement);
+ tip = Lute.EscapeHTMLStr(getCellText(aElement));
}
aElement.style.overflow = "";
}
diff --git a/app/src/protyle/render/av/cell.ts b/app/src/protyle/render/av/cell.ts
index 75725d6a00..09646390cf 100644
--- a/app/src/protyle/render/av/cell.ts
+++ b/app/src/protyle/render/av/cell.ts
@@ -30,9 +30,10 @@ const renderCellURL = (urlContent: string) => {
}
} catch (e) {
// 不是 url 地址
+ host = Lute.EscapeHTMLStr(urlContent);
}
// https://github.com/siyuan-note/siyuan/issues/9291
- return `<span class="av__celltext av__celltext--url" data-type="url" data-href="${urlContent}"><span>${host}</span><span class="ft__on-surface">${suffix}</span></span>`;
+ return `<span class="av__celltext av__celltext--url" data-type="url" data-href="${escapeAttr(urlContent)}"><span>${host}</span><span class="ft__on-surface">${suffix}</span></span>`;
};
export const getCellText = (cellElement: HTMLElement | false) => {
@@ -149,7 +150,7 @@ export const genCellValue = (colType: TAVCol, value: string | any) => {
cellValue = {
type: colType,
[colType]: {
- content: ["block", "text", "url", "phone", "email"].includes(colType) ? Lute.EscapeHTMLStr(value) : value
+ content: value
}
};
} else if (colType === "mSelect" || colType === "select") {
@@ -687,10 +688,12 @@ export const renderCellAttr = (cellElement: Element, value: IAVCellValue) => {
export const renderCell = (cellValue: IAVCellValue, rowIndex = 0) => {
let text = "";
- if (["text", "template"].includes(cellValue.type)) {
- text = `<span class="av__celltext">${cellValue ? (cellValue[cellValue.type as "text"].content || "") : ""}</span>`;
+ if ("template" === cellValue.type) {
+ text = `<span class="av__celltext">${cellValue ? (cellValue.template.content || "") : ""}</span>`;
+ } else if ("text" === cellValue.type) {
+ text = `<span class="av__celltext">${cellValue ? Lute.EscapeHTMLStr(cellValue.text.content || "") : ""}</span>`;
} else if (["email", "phone"].includes(cellValue.type)) {
- text = `<span class="av__celltext av__celltext--url" data-type="${cellValue.type}">${cellValue ? cellValue[cellValue.type as "email"].content : ""}</span>`;
+ text = `<span class="av__celltext av__celltext--url" data-type="${cellValue.type}">${cellValue ? Lute.EscapeHTMLStr(cellValue[cellValue.type as "email"].content || "") : ""}</span>`;
} else if ("url" === cellValue.type) {
text = renderCellURL(cellValue?.url?.content || "");
} else if (cellValue.type === "block") {