This commit is contained in:
Daniel 2024-11-27 20:13:22 +08:00
parent 18f68ac715
commit 7446599c0f
No known key found for this signature in database
GPG key ID: 86211BA83DF03017
18 changed files with 29 additions and 22 deletions

View file

@ -607,7 +607,7 @@ func RenameAsset(oldPath, newName string) (newPath string, err error) {
defer util.PushClearProgress()
newName = strings.TrimSpace(newName)
newName = gulu.Str.RemoveInvisible(newName)
newName = util.RemoveInvalid(newName)
if path.Base(oldPath) == newName {
return
}

View file

@ -566,7 +566,7 @@ func getUser(token string) (*conf.User, error) {
func UseActivationcode(code string) (err error) {
code = strings.TrimSpace(code)
code = gulu.Str.RemoveInvisible(code)
code = util.RemoveInvalid(code)
requestResult := gulu.Ret.NewResult()
request := httpclient.NewCloudRequest30s()
resp, err := request.
@ -590,7 +590,7 @@ func UseActivationcode(code string) (err error) {
func CheckActivationcode(code string) (retCode int, msg string) {
code = strings.TrimSpace(code)
code = gulu.Str.RemoveInvisible(code)
code = util.RemoveInvalid(code)
retCode = 1
requestResult := gulu.Ret.NewResult()
request := httpclient.NewCloudRequest30s()

View file

@ -609,7 +609,7 @@ func ExportDocx(id, savePath string, removeAssets, merge bool) (fullPath string,
}
// Pandoc template for exporting docx https://github.com/siyuan-note/siyuan/issues/8740
docxTemplate := gulu.Str.RemoveInvisible(Conf.Export.DocxTemplate)
docxTemplate := util.RemoveInvalid(Conf.Export.DocxTemplate)
docxTemplate = strings.TrimSpace(docxTemplate)
if "" != docxTemplate {
if !gulu.File.IsExist(docxTemplate) {

View file

@ -1936,7 +1936,7 @@ func createDoc(boxID, p, title, dom string) (tree *parse.Tree, err error) {
func removeInvisibleCharsInTitle(title string) string {
// 不要踢掉 零宽连字符,否则有的 Emoji 会变形 https://github.com/siyuan-note/siyuan/issues/11480
title = strings.ReplaceAll(title, string(gulu.ZWJ), "__@ZWJ@__")
title = gulu.Str.RemoveInvisible(title)
title = util.RemoveInvalid(title)
title = strings.ReplaceAll(title, "__@ZWJ@__", string(gulu.ZWJ))
return title
}

View file

@ -405,7 +405,7 @@ type HistoryItem struct {
const fileHistoryPageSize = 32
func FullTextSearchHistory(query, box, op string, typ, page int) (ret []string, pageCount, totalCount int) {
query = gulu.Str.RemoveInvisible(query)
query = util.RemoveInvalid(query)
if "" != query && HistoryTypeDocID != typ {
query = stringQuery(query)
}
@ -440,7 +440,7 @@ func FullTextSearchHistory(query, box, op string, typ, page int) (ret []string,
}
func FullTextSearchHistoryItems(created, query, box, op string, typ int) (ret []*HistoryItem) {
query = gulu.Str.RemoveInvisible(query)
query = util.RemoveInvalid(query)
if "" != query && HistoryTypeDocID != typ {
query = stringQuery(query)
}

View file

@ -67,6 +67,7 @@ func HTML2Markdown(htmlStr string, luteEngine *lute.Lute) (markdown string, with
}
func HTML2Tree(htmlStr string, luteEngine *lute.Lute) (tree *parse.Tree, withMath bool) {
htmlStr = util.RemoveInvalid(htmlStr)
assetDirPath := filepath.Join(util.DataDir, "assets")
tree = luteEngine.HTML2Tree(htmlStr)
ast.Walk(tree.Root, func(n *ast.Node, entering bool) ast.WalkStatus {

View file

@ -35,7 +35,7 @@ import (
)
func CreateBox(name string) (id string, err error) {
name = gulu.Str.RemoveInvisible(name)
name = util.RemoveInvalid(name)
if 512 < utf8.RuneCountInString(name) {
// 限制笔记本名和文档名最大长度为 `512` https://github.com/siyuan-note/siyuan/issues/6299
err = errors.New(Conf.Language(106))

View file

@ -1022,7 +1022,7 @@ func TagSnapshot(id, name string) (err error) {
}
name = strings.TrimSpace(name)
name = gulu.Str.RemoveInvisible(name)
name = util.RemoveInvalid(name)
if "" == name {
err = errors.New(Conf.Language(142))
return

View file

@ -1993,7 +1993,7 @@ func getRefSearchIgnoreLines() (ret []string) {
func filterQueryInvisibleChars(query string) string {
query = strings.ReplaceAll(query, " ", "_@full_width_space@_")
query = gulu.Str.RemoveInvisible(query)
query = util.RemoveInvalid(query)
query = strings.ReplaceAll(query, "_@full_width_space@_", " ")
return query
}

View file

@ -470,7 +470,7 @@ func CreateCloudSyncDir(name string) (err error) {
}
name = strings.TrimSpace(name)
name = gulu.Str.RemoveInvisible(name)
name = util.RemoveInvalid(name)
if !cloud.IsValidCloudDirName(name) {
return errors.New(Conf.Language(37))
}

View file

@ -33,6 +33,7 @@ import (
"github.com/siyuan-note/siyuan/kernel/sql"
"github.com/siyuan-note/siyuan/kernel/task"
"github.com/siyuan-note/siyuan/kernel/treenode"
"github.com/siyuan-note/siyuan/kernel/util"
)
// virtualBlockRefCache 用于保存块关联的虚拟引用关键字。
@ -170,7 +171,7 @@ func processVirtualRef(n *ast.Node, unlinks *[]*ast.Node, virtualBlockRefKeyword
}
content := string(n.Tokens)
tmp := gulu.Str.RemoveInvisible(content)
tmp := util.RemoveInvalid(content)
tmp = strings.TrimSpace(tmp)
if "" == tmp {
return false