Skip to content

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

:bug: Fix block ref search sorting https://github.com/siyuan-note/siyuan/issues/10164 https://github.com/siyuan-note/siyuan/issues/8886

Danielb2500139ebf3
diff --git a/kernel/model/search.go b/kernel/model/search.go
index 328f825906..45345569d5 100644
--- a/kernel/model/search.go
+++ b/kernel/model/search.go
@@ -948,7 +948,7 @@ func fullTextSearchRefBlock(keyword string, beforeLen int, onlyDoc bool) (ret []
when memo LIKE '%${keyword}%' then 90
when content LIKE '%${keyword}%' and type != 'i' and type != 'l' then 100
else 65535 end ASC, sort ASC, length ASC`
- orderBy = strings.ReplaceAll(orderBy, "${keyword}", quotedKeyword)
+ orderBy = strings.ReplaceAll(orderBy, "${keyword}", strings.ReplaceAll(keyword, "'", "''"))
stmt += orderBy + " LIMIT " + strconv.Itoa(Conf.Search.Limit)
blocks := sql.SelectBlocksRawStmtNoParse(stmt, Conf.Search.Limit)
ret = fromSQLBlocks(&blocks, "", beforeLen)