Skip to content

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

:bug: Encode database attribute value snapshots https://github.com/siyuan-note/siyuan/issues/18340

Danielb34ea78564ba
diff --git a/app/src/protyle/render/av/attributeValue.ts b/app/src/protyle/render/av/attributeValue.ts
index 463fd460d9..72d0ce4c1c 100644
--- a/app/src/protyle/render/av/attributeValue.ts
+++ b/app/src/protyle/render/av/attributeValue.ts
@@ -204,7 +204,7 @@ export const genAVAttributeRowHTML = (options: {
${options.icon ? unicode2Emoji(options.icon, "block__logoicon", true) : `<svg class="block__logoicon"><use xlink:href="#${options.typeIcon}"></use></svg>`}
<span>${escapeHtml(options.name)}</span>
</div>
- <div data-av-id="${options.avID}" data-col-id="${value.keyID}" data-row-id="${value.blockID}"${value.id ? ` data-id="${value.id}"` : ""} data-value="${escapeAttr(JSON.stringify(value))}" data-type="${value.type}"${value.isDetached ? ' data-detached="true"' : ""}
+ <div data-av-id="${options.avID}" data-col-id="${value.keyID}" data-row-id="${value.blockID}"${value.id ? ` data-id="${value.id}"` : ""} data-cell-value="${encodeURIComponent(JSON.stringify(value))}" data-type="${value.type}"${value.isDetached ? ' data-detached="true"' : ""}
data-options="${options.selectOptions ? escapeAttr(JSON.stringify(options.selectOptions)) : "[]"}"
${hasOwnPlaceholder ? "" : `placeholder="${window.siyuan.languages.empty}"`}
class="fn__flex-1 fn__flex${textInputType ? "" : " custom-attr__avvalue"}${["created", "updated"].includes(value.type) ? " custom-attr__avvalue--readonly" : ""}">${genAVValueHTML(value)}</div>
diff --git a/app/src/protyle/render/av/cell.ts b/app/src/protyle/render/av/cell.ts
index eaa2450ac9..ab6a0a751c 100644
--- a/app/src/protyle/render/av/cell.ts
+++ b/app/src/protyle/render/av/cell.ts
@@ -64,8 +64,8 @@ export const getCellText = (cellElement: HTMLElement | false) => {
};
export const genCellValueByElement = (colType: TAVCol, cellElement: HTMLElement) => {
- if (cellElement.dataset.avId && cellElement.dataset.value) {
- return JSON.parse(cellElement.dataset.value) as IAVCellValue;
+ if (cellElement.dataset.avId && cellElement.dataset.cellValue) {
+ return JSON.parse(decodeURIComponent(cellElement.dataset.cellValue)) as IAVCellValue;
}
const cellValue: IAVCellValue = {
type: colType,
@@ -961,7 +961,7 @@ export const updateAttrViewCellInOtherElements = (protyle: IProtyle, avID: strin
} else {
cellElement.removeAttribute("data-id");
}
- cellElement.dataset.value = JSON.stringify(value);
+ cellElement.dataset.cellValue = encodeURIComponent(JSON.stringify(value));
cellElement.parentElement.dataset.empty = cellValueIsEmpty(value).toString();
};
if (sourceElement?.dataset.avId) {