From 4baeeed1ecb7454e532fb5f4be72fca855b29585 Mon Sep 17 00:00:00 2001 From: Daniel <845765@qq.com> Date: Sun, 27 Aug 2023 10:53:48 +0800 Subject: [PATCH] :art: Non-UTF-8 encoded text files are not included in asset file content searching Fix https://github.com/siyuan-note/siyuan/issues/9052 --- kernel/model/asset_content.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/kernel/model/asset_content.go b/kernel/model/asset_content.go index 2ba193b8e..c5ac3c7d9 100644 --- a/kernel/model/asset_content.go +++ b/kernel/model/asset_content.go @@ -26,6 +26,7 @@ import ( "strings" "sync" "time" + "unicode/utf8" "code.sajari.com/docconv" "github.com/88250/gulu" @@ -516,6 +517,11 @@ func (parser *TxtAssetParser) Parse(absPath string) (ret *AssetParseResult) { return } + if !utf8.Valid(data) { + // Non-UTF-8 encoded text files are not included in asset file content searching https://github.com/siyuan-note/siyuan/issues/9052 + return + } + content := string(data) ret = &AssetParseResult{ Content: content,