Skip to content

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

:lock: Prevent stored XSS in attribute view textarea editors https://github.com/siyuan-note/siyuan/security/advisories/GHSA-h3p6-c22r-fx2j

Daniel37cc0ee7aaaf
diff --git a/app/src/protyle/render/av/calc.ts b/app/src/protyle/render/av/calc.ts
index 21c00c0796..8e0fbf3911 100644
--- a/app/src/protyle/render/av/calc.ts
+++ b/app/src/protyle/render/av/calc.ts
@@ -5,7 +5,7 @@ import {fetchSyncPost} from "../../../util/fetch";
import {getFieldsByData} from "./view";
import {Constants} from "../../../constants";
import {Dialog} from "../../../dialog";
-import {escapeAttr} from "../../../util/escape";
+import {escapeAttr, escapeHtml} from "../../../util/escape";
import {getAVTemplateHTML} from "./attributeValue";
const calcItem = (options: {
@@ -481,7 +481,7 @@ export const openCalcMenu = async (protyle: IProtyle, calcElement: HTMLElement,
const dialog = new Dialog({
title: window.siyuan.languages.calcOperatorTemplate,
content: `<div class="b3-dialog__content">
- <textarea spellcheck="false" class="fn__block b3-text-field" placeholder="${escapeAttr(window.siyuan.languages.rollupTemplateTip)}" rows="8" style="resize: vertical;font-family: var(--b3-font-family-code);">${currentTemplate}</textarea>
+ <textarea spellcheck="false" class="fn__block b3-text-field" placeholder="${escapeAttr(window.siyuan.languages.rollupTemplateTip)}" rows="8" style="resize: vertical;font-family: var(--b3-font-family-code);">${escapeHtml(currentTemplate)}</textarea>
</div>
<div class="b3-dialog__action">
<button class="b3-button b3-button--cancel">${window.siyuan.languages.cancel}</button><div class="fn__space"></div>
diff --git a/app/src/protyle/render/av/col.ts b/app/src/protyle/render/av/col.ts
index 149e47d74c..0b7a239fe4 100644
--- a/app/src/protyle/render/av/col.ts
+++ b/app/src/protyle/render/av/col.ts
@@ -161,7 +161,7 @@ export const getEditHTML = (options: {
} else if (colData.type === "template") {
html += `<button class="b3-menu__separator" data-id="separator_2"></button>
<button class="b3-menu__item" data-type="nobg">
- <textarea spellcheck="false" rows="${Math.min(colData.template.split("\n").length, 8)}" placeholder="${window.siyuan.languages.template}" data-type="updateTemplate" style="margin: 4px 0" rows="1" class="fn__block b3-text-field">${colData.template}</textarea>
+ <textarea spellcheck="false" rows="${Math.min(colData.template.split("\n").length, 8)}" placeholder="${window.siyuan.languages.template}" data-type="updateTemplate" style="margin: 4px 0" rows="1" class="fn__block b3-text-field">${escapeHtml(colData.template)}</textarea>
</button>`;
} else if (colData.type === "relation") {
const isSelf = colData.relation?.avID === options.data.id;
@@ -1008,7 +1008,7 @@ export const showColMenu = (protyle: IProtyle, blockElement: Element, cellElemen
<div class="fn__hr"></div>
<div class="fn__flex">
<span class="fn__space"></span>
- <textarea placeholder="${window.siyuan.languages.addDesc}" rows="1" class="b3-text-field fn__block" type="text" data-value="${escapeAttr(oldDesc)}">${oldDesc}</textarea>
+ <textarea placeholder="${window.siyuan.languages.addDesc}" rows="1" class="b3-text-field fn__block" type="text" data-value="${escapeAttr(oldDesc)}">${escapeHtml(oldDesc)}</textarea>
<span class="fn__space"></span>
</div>
</div>
diff --git a/app/src/protyle/render/av/select.ts b/app/src/protyle/render/av/select.ts
index 6ec8216e42..2dae7a51f1 100644
--- a/app/src/protyle/render/av/select.ts
+++ b/app/src/protyle/render/av/select.ts
@@ -283,7 +283,7 @@ export const setColOption = (protyle: IProtyle, data: IAV, target: HTMLElement,
</div>
<div class="fn__none">
<div class="fn__hr"></div>
- <textarea rows="1" placeholder="${window.siyuan.languages.addDesc}" class="b3-text-field fn__block" type="text" data-value="${escapeAttr(desc)}">${desc}</textarea>
+ <textarea rows="1" placeholder="${window.siyuan.languages.addDesc}" class="b3-text-field fn__block" type="text" data-value="${escapeAttr(desc)}">${escapeHtml(desc)}</textarea>
</div>
<div class="fn__hr--small"></div>`,
bind(element) {