Skip to content

Commit

Permalink
🐛 Fix HTML tag search escaping #13354
Browse files Browse the repository at this point in the history
  • Loading branch information
88250 committed Dec 8, 2024
1 parent 4970374 commit 67f64f7
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
3 changes: 1 addition & 2 deletions kernel/model/search.go
Original file line number Diff line number Diff line change
Expand Up @@ -1459,8 +1459,7 @@ func fullTextSearchCountByFTS(query, boxFilter, pathFilter, typeFilter, ignoreFi
}

func fullTextSearchByLikeWithRoot(query, boxFilter, pathFilter, typeFilter, ignoreFilter, orderBy string, beforeLen, page, pageSize int) (ret []*Block, matchedBlockCount, matchedRootCount int) {
query = strings.ReplaceAll(query, "'", "''")
query = strings.ReplaceAll(query, "\"", "\"\"")
query = strings.ReplaceAll(query, "'", "''") // 不需要转义双引号,因为条件都是通过单引号包裹的,只需要转义单引号即可
keywords := strings.Split(query, " ")
contentField := columnConcat()
var likeFilter string
Expand Down
3 changes: 2 additions & 1 deletion kernel/search/mark.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (

"github.com/88250/gulu"
"github.com/88250/lute/lex"
"github.com/siyuan-note/siyuan/kernel/util"
)

func MarkText(text string, keyword string, beforeLen int, caseSensitive bool) (pos int, marked string) {
Expand Down Expand Up @@ -112,7 +113,7 @@ func EncloseHighlighting(text string, keywords []string, openMark, closeMark str
ret = text

if reg, err := regexp.Compile(re); err == nil {
ret = reg.ReplaceAllStringFunc(text, func(s string) string { return openMark + s + closeMark })
ret = reg.ReplaceAllStringFunc(text, func(s string) string { return openMark + util.EscapeHTML(s) + closeMark })
}

// 搜索结果预览包含转义符问题 Search results preview contains escape character issue https://github.com/siyuan-note/siyuan/issues/9790
Expand Down

0 comments on commit 67f64f7

Please sign in to comment.