From 425bb8c425f1640275f14b5683d6d6b076c5ad84 Mon Sep 17 00:00:00 2001 From: Liang Ding Date: Mon, 28 Nov 2022 18:07:33 +0800 Subject: [PATCH 1/2] =?UTF-8?q?:bug:=20=E6=9F=A5=E6=89=BE=E6=9B=BF?= =?UTF-8?q?=E6=8D=A2=E4=B8=AD=E4=BD=BF=E7=94=A8=E6=AD=A3=E5=88=99=E8=A1=A8?= =?UTF-8?q?=E8=BE=BE=E5=BC=8F=E5=90=8E=E6=9B=BF=E6=8D=A2=E4=B8=8D=E6=AD=A3?= =?UTF-8?q?=E7=A1=AE=20https://github.com/siyuan-note/siyuan/issues/6722?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kernel/model/search.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/kernel/model/search.go b/kernel/model/search.go index 07f9cef0d..3da69d614 100644 --- a/kernel/model/search.go +++ b/kernel/model/search.go @@ -563,16 +563,16 @@ func fullTextSearchByRegexp(exp, box, path, typeFilter string, beforeLen int) (r return } -func fullTextSearchCountByRegexp(exp, box, path, filter string) (matchedBlockCount, matchedRootCount int) { +func fullTextSearchCountByRegexp(exp, box, path, typeFilter string) (matchedBlockCount, matchedRootCount int) { fieldFilter := fieldRegexp(exp) - stmt := "SELECT COUNT(id) AS `matches`, COUNT(DISTINCT(root_id)) AS `docs` FROM `blocks` WHERE " + fieldFilter + " AND type IN " + filter + stmt := "SELECT COUNT(id) AS `matches`, COUNT(DISTINCT(root_id)) AS `docs` FROM `blocks` WHERE " + fieldFilter + " AND type IN " + typeFilter if "" != box { stmt += " AND box = '" + box + "'" } if "" != path { stmt += " AND path LIKE '" + path + "%'" } - stmt += " ORDER BY sort ASC LIMIT " + strconv.Itoa(Conf.Search.Limit) + stmt += " LIMIT " + strconv.Itoa(Conf.Search.Limit) result, _ := sql.Query(stmt) if 1 > len(result) { return From 934ea789a0017e9607708b1e876ddc914287eb86 Mon Sep 17 00:00:00 2001 From: Liang Ding Date: Mon, 28 Nov 2022 18:16:15 +0800 Subject: [PATCH 2/2] =?UTF-8?q?:bug:=20=E6=9F=A5=E6=89=BE=E6=9B=BF?= =?UTF-8?q?=E6=8D=A2=E4=B8=AD=E4=BD=BF=E7=94=A8=E6=AD=A3=E5=88=99=E8=A1=A8?= =?UTF-8?q?=E8=BE=BE=E5=BC=8F=E5=90=8E=E6=9B=BF=E6=8D=A2=E4=B8=8D=E6=AD=A3?= =?UTF-8?q?=E7=A1=AE=20https://github.com/siyuan-note/siyuan/issues/6722?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kernel/model/search.go | 1 + 1 file changed, 1 insertion(+) diff --git a/kernel/model/search.go b/kernel/model/search.go index 3da69d614..3eec57acb 100644 --- a/kernel/model/search.go +++ b/kernel/model/search.go @@ -543,6 +543,7 @@ func fullTextSearch(query, box, path, typeFilter string, beforeLen int, querySyn func fullTextSearchByRegexp(exp, box, path, typeFilter string, beforeLen int) (ret []*Block, matchedBlockCount, matchedRootCount int) { exp = gulu.Str.RemoveInvisible(exp) + exp = regexp.QuoteMeta(exp) fieldFilter := fieldRegexp(exp) stmt := "SELECT * FROM `blocks` WHERE (" + fieldFilter + ") AND type IN " + typeFilter