Skip to content

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

:art: Database index content/markdown values no longer contain zero-width spaces https://github.com/siyuan-note/siyuan/issues/15204

Daniel286223db842c
diff --git a/kernel/model/blockial.go b/kernel/model/blockial.go
index 2d64f1bd39..c7637b8f8b 100644
--- a/kernel/model/blockial.go
+++ b/kernel/model/blockial.go
@@ -24,6 +24,7 @@ import (
"github.com/88250/gulu"
"github.com/88250/lute/ast"
+ "github.com/88250/lute/editor"
"github.com/88250/lute/lex"
"github.com/88250/lute/parse"
"github.com/araddon/dateparse"
@@ -69,6 +70,7 @@ func SetBlockReminder(id string, timed string) (err error) {
}
content := sql.NodeStaticContent(node, nil, false, false, false)
content = gulu.Str.SubStr(content, 128)
+ content = strings.ReplaceAll(content, editor.Zwsp, "")
err = SetCloudBlockReminder(id, content, timedMills)
if err != nil {
return
diff --git a/kernel/model/virutalref.go b/kernel/model/virutalref.go
index e769ded356..88f7319b3f 100644
--- a/kernel/model/virutalref.go
+++ b/kernel/model/virutalref.go
@@ -26,6 +26,7 @@ import (
"github.com/88250/gulu"
"github.com/88250/lute"
"github.com/88250/lute/ast"
+ "github.com/88250/lute/editor"
"github.com/88250/lute/parse"
"github.com/ClarkThan/ahocorasick"
"github.com/dgraph-io/ristretto"
@@ -54,6 +55,7 @@ func getBlockVirtualRefKeywords(root *ast.Node) (ret []string) {
}
content := sql.NodeStaticContent(n, nil, false, false, false)
+ content = strings.ReplaceAll(content, editor.Zwsp, "")
buf.WriteString(content)
return ast.WalkContinue
})
diff --git a/kernel/sql/block.go b/kernel/sql/block.go
index 6b9514f388..920ed99951 100644
--- a/kernel/sql/block.go
+++ b/kernel/sql/block.go
@@ -23,6 +23,7 @@ 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"
@@ -117,6 +118,7 @@ func indexNode(tx *sql.Tx, id string) (err error) {
}
content := NodeStaticContent(node, nil, true, indexAssetPath, true)
+ content = strings.ReplaceAll(content, editor.Zwsp, "")
stmt := "UPDATE blocks SET content = ? WHERE id = ?"
if err = execStmtTx(tx, stmt, content, id); err != nil {
tx.Rollback()
diff --git a/kernel/sql/database.go b/kernel/sql/database.go
index f2349d2046..e8458cf40e 100644
--- a/kernel/sql/database.go
+++ b/kernel/sql/database.go
@@ -36,6 +36,7 @@ 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/mattn/go-sqlite3"
@@ -867,6 +868,11 @@ func buildBlockFromNode(n *ast.Node, tree *parse.Tree) (block *Block, attributes
length = utf8.RuneCountInString(content)
}
+ // 剔除零宽空格 Database index content/markdown values no longer contain zero-width spaces https://github.com/siyuan-note/siyuan/issues/15204
+ fcontent = strings.ReplaceAll(fcontent, editor.Zwsp, "")
+ content = strings.ReplaceAll(content, editor.Zwsp, "")
+ markdown = strings.ReplaceAll(markdown, editor.Zwsp, "")
+
block = &Block{
ID: n.ID,
ParentID: parentID,