An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:bug: https://github.com/siyuan-note/siyuan/issues/17345
Daniel1bc7f556ff86
diff --git a/kernel/cache/ial.go b/kernel/cache/ial.goindex 2cb72c03cb..7cbe9b7bc2 100644--- a/kernel/cache/ial.go+++ b/kernel/cache/ial.go@@ -61,6 +61,7 @@ var blockIALCache, _ = ristretto.NewCache(&ristretto.Config{})func PutBlockIAL(id string, ial map[string]string) {+ // 这里存入的属性值都是反转义过的,用的是 parse.IAL2Map(),而不是 parse.IAL2MapUnEsc()blockIALCache.Set(id, ial, 128)}diff --git a/kernel/model/attribute_view.go b/kernel/model/attribute_view.goindex 75d5213917..e265241398 100644--- a/kernel/model/attribute_view.go+++ b/kernel/model/attribute_view.go@@ -2816,14 +2816,14 @@ func (tx *Transaction) doRemoveAttrViewView(operation *Operation) (ret *TxErr) {if blockViewID == viewID {attrs[av.NodeAttrView] = attrView.ViewIDnode.AttributeViewType = string(view.LayoutType)- oldAttrs, e := setNodeAttrs0(node, attrs)+ oldAttrsUnEsc, e := setNodeAttrs0(node, attrs)if nil != e {logging.LogErrorf("set node attrs failed: %s", e)continue}cache.PutBlockIAL(node.ID, parse.IAL2Map(node.KramdownIAL))- pushBlockAttrs(oldAttrs, node)+ pushBlockAttrs(oldAttrsUnEsc, node)}}@@ -5826,12 +5826,12 @@ func updateBoundBlockAvsAttribute(avIDs []string) {attrs[av.NodeAttrViewNames] = avNames}- oldAttrs, setErr := setNodeAttrs0(node, attrs)+ oldAttrsUnEsc, setErr := setNodeAttrs0(node, attrs)if nil != setErr {continue}cache.PutBlockIAL(node.ID, parse.IAL2Map(node.KramdownIAL))- pushBlockAttrs(oldAttrs, node)+ pushBlockAttrs(oldAttrsUnEsc, node)if "" != avNames {node.RemoveIALAttr(av.NodeAttrViewNames)}diff --git a/kernel/model/blockial.go b/kernel/model/blockial.goindex 3640e50dcb..e1922ef682 100644--- a/kernel/model/blockial.go+++ b/kernel/model/blockial.go@@ -126,13 +126,13 @@ func BatchSetBlockAttrs(blockAttrs []map[string]interface{}) (err error) {}attrs := blockAttr["attrs"].(map[string]string)- oldAttrs, e := setNodeAttrs0(node, attrs)+ oldAttrsUnEsc, e := setNodeAttrs0(node, attrs)if nil != e {return e}cache.PutBlockIAL(node.ID, parse.IAL2Map(node.KramdownIAL))- pushBlockAttrs(oldAttrs, node)+ pushBlockAttrs(oldAttrsUnEsc, node)nodes = append(nodes, node)}@@ -169,7 +169,7 @@ func SetBlockAttrs(id string, nameValues map[string]string) (err error) {}func setNodeAttrs(node *ast.Node, tree *parse.Tree, nameValues map[string]string) (err error) {- oldAttrs, err := setNodeAttrs0(node, nameValues)+ oldAttrsUnEsc, err := setNodeAttrs0(node, nameValues)if err != nil {return}@@ -181,7 +181,7 @@ func setNodeAttrs(node *ast.Node, tree *parse.Tree, nameValues map[string]stringIncSync()cache.PutBlockIAL(node.ID, parse.IAL2Map(node.KramdownIAL))- pushBlockAttrs(oldAttrs, node)+ pushBlockAttrs(oldAttrsUnEsc, node)go func() {sql.FlushQueue()@@ -191,7 +191,7 @@ func setNodeAttrs(node *ast.Node, tree *parse.Tree, nameValues map[string]string}func setNodeAttrsWithTx(tx *Transaction, node *ast.Node, tree *parse.Tree, nameValues map[string]string) (err error) {- oldAttrs, err := setNodeAttrs0(node, nameValues)+ oldAttrsUnEsc, err := setNodeAttrs0(node, nameValues)if err != nil {return}@@ -200,13 +200,13 @@ func setNodeAttrsWithTx(tx *Transaction, node *ast.Node, tree *parse.Tree, nameVIncSync()cache.PutBlockIAL(node.ID, parse.IAL2Map(node.KramdownIAL))- pushBlockAttrs(oldAttrs, node)+ pushBlockAttrs(oldAttrsUnEsc, node)return}-func setNodeAttrs0(node *ast.Node, nameValues map[string]string) (oldAttrs map[string]string, err error) {- oldAttrs = parse.IAL2Map(node.KramdownIAL)- newAttrs := maps.Clone(oldAttrs)+func setNodeAttrs0(node *ast.Node, nameValues map[string]string) (oldAttrsUnEsc map[string]string, err error) {+ oldAttrsUnEsc = parse.IAL2MapUnEsc(node.KramdownIAL)+ newAttrsUnEsc := maps.Clone(oldAttrsUnEsc)for name, value := range nameValues {value = util.RemoveInvalidRetainCtrl(value)@@ -239,25 +239,25 @@ func setNodeAttrs0(node *ast.Node, nameValues map[string]string) (oldAttrs map[sif "" == value {// 删除属性if name != lowerName {- if _, exists := newAttrs[name]; exists {+ if _, exists := newAttrsUnEsc[name]; exists {// 仅删除完全匹配的包含大写字母的属性- delete(newAttrs, name)+ delete(newAttrsUnEsc, name)continue}}- delete(newAttrs, lowerName)+ delete(newAttrsUnEsc, lowerName)} else {// 添加或更新属性// 删除大小写完全匹配的属性- delete(newAttrs, name)+ delete(newAttrsUnEsc, name)// 保存小写的属性 https://github.com/siyuan-note/siyuan/issues/16447- newAttrs[lowerName] = html.EscapeAttrVal(value)+ newAttrsUnEsc[lowerName] = html.EscapeAttrVal(value)}}- node.KramdownIAL = parse.Map2IAL(newAttrs)+ node.KramdownIAL = parse.Map2IAL(newAttrsUnEsc)- if oldAttrs["tags"] != newAttrs["tags"] {+ if oldAttrsUnEsc["tags"] != newAttrsUnEsc["tags"] {ReloadTag()}return@@ -280,7 +280,7 @@ func ResetBlockAttrs(id string, nameValues map[string]string) (err error) {return errors.New(fmt.Sprintf(Conf.Language(15), id))}- oldAttrs := parse.IAL2Map(node.KramdownIAL)+ oldAttrs := parse.IAL2MapUnEsc(node.KramdownIAL)node.ClearIALAttrs()_, err = setNodeAttrs0(node, nameValues)@@ -349,9 +349,9 @@ func validateChars(name string, startIdx, n int) bool {return true}-func pushBlockAttrs(oldAttrs map[string]string, node *ast.Node) {- newAttrs := parse.IAL2Map(node.KramdownIAL)- data := map[string]interface{}{"old": oldAttrs, "new": newAttrs}+func pushBlockAttrs(oldAttrsUnEsc map[string]string, node *ast.Node) {+ newAttrsUnEsc := parse.IAL2MapUnEsc(node.KramdownIAL)+ data := map[string]interface{}{"old": oldAttrsUnEsc, "new": newAttrsUnEsc}if "" != node.AttributeViewType {data["data-av-type"] = node.AttributeViewType}diff --git a/kernel/model/transaction.go b/kernel/model/transaction.goindex 2647cd348c..acc14567b4 100644--- a/kernel/model/transaction.go+++ b/kernel/model/transaction.go@@ -1546,7 +1546,7 @@ func (tx *Transaction) doUpdate(operation *Operation) (ret *TxErr) {// updateBlock 会清空数据库角标 https://github.com/siyuan-note/siyuan/issues/16549go func() {time.Sleep(200 * time.Millisecond)- oldAttrs := parse.IAL2Map(updatedNode.KramdownIAL)+ oldAttrs := parse.IAL2MapUnEsc(updatedNode.KramdownIAL)updatedNode.SetIALAttr(av.NodeAttrViewNames, avNames)pushBlockAttrs(oldAttrs, updatedNode)}()