From 7475d79ba5ab2e619dfd4c6fbf8f6fd149a6c605 Mon Sep 17 00:00:00 2001 From: Daniel <845765@qq.com> Date: Thu, 22 Jun 2023 16:58:24 +0800 Subject: [PATCH] :bug: Breadcrumbs are escaped multiple times Fix https://github.com/siyuan-note/siyuan/issues/8580 --- kernel/model/blockinfo.go | 5 ++--- kernel/model/graph.go | 14 -------------- kernel/model/search.go | 3 +-- 3 files changed, 3 insertions(+), 19 deletions(-) diff --git a/kernel/model/blockinfo.go b/kernel/model/blockinfo.go index 3aa4f8e0e..17790790b 100644 --- a/kernel/model/blockinfo.go +++ b/kernel/model/blockinfo.go @@ -27,7 +27,6 @@ import ( "github.com/88250/gulu" "github.com/88250/lute/ast" "github.com/88250/lute/editor" - "github.com/88250/lute/html" "github.com/88250/lute/parse" "github.com/siyuan-note/logging" "github.com/siyuan-note/siyuan/kernel/sql" @@ -310,7 +309,7 @@ func buildBlockBreadcrumb(node *ast.Node, excludeTypes []string) (ret []*BlockPa if add { ret = append([]*BlockPath{{ ID: id, - Name: html.EscapeString(name), + Name: util.EscapeHTML(name), Type: parent.Type.String(), SubType: treenode.SubTypeAbbr(parent), }}, ret...) @@ -331,7 +330,7 @@ func buildBlockBreadcrumb(node *ast.Node, excludeTypes []string) (ret []*BlockPa name = gulu.Str.SubStr(renderBlockText(b, excludeTypes), maxNameLen) ret = append([]*BlockPath{{ ID: b.ID, - Name: html.EscapeString(name), + Name: util.EscapeHTML(name), Type: b.Type.String(), SubType: treenode.SubTypeAbbr(b), }}, ret...) diff --git a/kernel/model/graph.go b/kernel/model/graph.go index 8f8c21b04..d03359b47 100644 --- a/kernel/model/graph.go +++ b/kernel/model/graph.go @@ -522,20 +522,6 @@ func nodeContentByBlock(block *Block) (ret string) { return } -func nodeContentByNode(node *ast.Node, text string) (ret string) { - if ret = node.IALAttr("name"); "" != ret { - return - } - if ret = node.IALAttr("memo"); "" != ret { - return - } - if maxLen := 48; maxLen < utf8.RuneCountInString(text) { - text = gulu.Str.SubStr(text, maxLen) + "..." - } - ret = html.EscapeString(text) - return -} - func graphTypeFilter(local bool) string { var inList []string diff --git a/kernel/model/search.go b/kernel/model/search.go index 6f627a70e..3a2625aa7 100644 --- a/kernel/model/search.go +++ b/kernel/model/search.go @@ -33,7 +33,6 @@ import ( "github.com/88250/gulu" "github.com/88250/lute" "github.com/88250/lute/ast" - "github.com/88250/lute/html" "github.com/88250/lute/lex" "github.com/88250/lute/parse" "github.com/88250/vitess-sqlparser/sqlparser" @@ -887,7 +886,7 @@ func fromSQLBlock(sqlBlock *sql.Block, terms string, beforeLen int) (block *Bloc } id := sqlBlock.ID - content := html.EscapeString(sqlBlock.Content) // Search dialog XSS https://github.com/siyuan-note/siyuan/issues/8525 + content := util.EscapeHTML(sqlBlock.Content) // Search dialog XSS https://github.com/siyuan-note/siyuan/issues/8525 content, _ = markSearch(content, terms, beforeLen) content = maxContent(content, 5120) markdown := maxContent(sqlBlock.Markdown, 5120)