Skip to content

Commit

Permalink
🎨 HTML tag search escaping issue #13354
Browse files Browse the repository at this point in the history
  • Loading branch information
88250 committed Dec 11, 2024
1 parent b0b88d3 commit 7e3ce7b
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 0 additions & 1 deletion kernel/model/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions kernel/model/search.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{}
Expand All @@ -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 {
Expand Down

0 comments on commit 7e3ce7b

Please sign in to comment.