Skip to content

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

:art: HTML tag search escaping issue https://github.com/siyuan-note/siyuan/issues/13354

Daniel7e3ce7b6d923
diff --git a/kernel/model/file.go b/kernel/model/file.go
index 4f78f83570..ce3dc59b48 100644
--- a/kernel/model/file.go
+++ b/kernel/model/file.go
@@ -798,7 +798,6 @@ func GetDoc(startID, endID, id string, index int, query string, queryTypes map[s
typeFilter := buildTypeFilter(queryTypes)
switch queryMethod {
case 0:
- query = strings.ReplaceAll(query, "'", "''") // 不需要转义双引号,因为条件都是通过单引号包裹的,只需要转义单引号即可
keywords = strings.Split(query, " ")
case 1:
keywords = highlightByFTS(query, typeFilter, rootID)
diff --git a/kernel/model/search.go b/kernel/model/search.go
index 68c8fdc6a0..fb35588003 100644
--- a/kernel/model/search.go
+++ b/kernel/model/search.go
@@ -1506,6 +1506,7 @@ func fullTextSearchByLikeWithRoot(query, boxFilter, pathFilter, typeFilter, igno
keywords = gulu.Str.RemoveDuplicatedElem(keywords)
terms := strings.Join(keywords, search.TermSep)
+ terms = strings.ReplaceAll(terms, "''", "'")
ret = fromSQLBlocks(&resultBlocks, terms, beforeLen)
if 1 > len(ret) {
ret = []*Block{}
@@ -1514,6 +1515,7 @@ func fullTextSearchByLikeWithRoot(query, boxFilter, pathFilter, typeFilter, igno
}
func highlightByFTS(query, typeFilter, id string) (ret []string) {
+ query = stringQuery(query)
const limit = 256
table := "blocks_fts"
if !Conf.Search.CaseSensitive {