浏览代码

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

Vanessa 1 年之前
父节点
当前提交
17e77274fa
共有 2 个文件被更改,包括 10 次插入7 次删除
  1. 2 2
      app/src/block/popover.ts
  2. 8 5
      app/src/protyle/render/av/cell.ts

+ 2 - 2
app/src/block/popover.ts

@@ -32,13 +32,13 @@ export const initBlockPopover = (app: App) => {
                 } else {
                 } else {
                     if (aElement.firstElementChild?.getAttribute("data-type") === "url") {
                     if (aElement.firstElementChild?.getAttribute("data-type") === "url") {
                         if (aElement.firstElementChild.textContent.indexOf("...") > -1) {
                         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")) {
                     if (!tip && aElement.dataset.wrap !== "true" && event.target.dataset.type !== "block-more" && !hasClosestByClassName(event.target, "block__icon")) {
                         aElement.style.overflow = "auto";
                         aElement.style.overflow = "auto";
                         if (aElement.scrollWidth > aElement.clientWidth + 2) {
                         if (aElement.scrollWidth > aElement.clientWidth + 2) {
-                            tip = getCellText(aElement);
+                            tip = Lute.EscapeHTMLStr(getCellText(aElement));
                         }
                         }
                         aElement.style.overflow = "";
                         aElement.style.overflow = "";
                     }
                     }

+ 8 - 5
app/src/protyle/render/av/cell.ts

@@ -30,9 +30,10 @@ const renderCellURL = (urlContent: string) => {
         }
         }
     } catch (e) {
     } catch (e) {
         // 不是 url 地址
         // 不是 url 地址
+        host = Lute.EscapeHTMLStr(urlContent);
     }
     }
     // https://github.com/siyuan-note/siyuan/issues/9291
     // 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) => {
 export const getCellText = (cellElement: HTMLElement | false) => {
@@ -149,7 +150,7 @@ export const genCellValue = (colType: TAVCol, value: string | any) => {
             cellValue = {
             cellValue = {
                 type: colType,
                 type: colType,
                 [colType]: {
                 [colType]: {
-                    content: ["block", "text", "url", "phone", "email"].includes(colType) ? Lute.EscapeHTMLStr(value) : value
+                    content: value
                 }
                 }
             };
             };
         } else if (colType === "mSelect" || colType === "select") {
         } else if (colType === "mSelect" || colType === "select") {
@@ -687,10 +688,12 @@ export const renderCellAttr = (cellElement: Element, value: IAVCellValue) => {
 
 
 export const renderCell = (cellValue: IAVCellValue, rowIndex = 0) => {
 export const renderCell = (cellValue: IAVCellValue, rowIndex = 0) => {
     let text = "";
     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)) {
     } 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) {
     } else if ("url" === cellValue.type) {
         text = renderCellURL(cellValue?.url?.content || "");
         text = renderCellURL(cellValue?.url?.content || "");
     } else if (cellValue.type === "block") {
     } else if (cellValue.type === "block") {