mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-02-20 22:14:06 +01:00
🎨 Remove Unicode PUA characters https://github.com/siyuan-note/siyuan/issues/13291
This commit is contained in:
parent
18f68ac715
commit
7446599c0f
18 changed files with 29 additions and 22 deletions
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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))
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue