Merge remote-tracking branch 'origin/dev' into dev

This commit is contained in:
Vanessa 2023-09-17 22:26:48 +08:00
commit 40218fa1a0
5 changed files with 35 additions and 12 deletions

View file

@ -29,6 +29,7 @@ Below are the detailed changes in this version.
* [Improve prompts for deleting bookmarks](https://github.com/siyuan-note/siyuan/issues/9196)
* [Improve the stability of creating data snapshots and data sync](https://github.com/siyuan-note/siyuan/issues/9197)
* [Automatically move corrupted notebook folders to the corrupted folder](https://github.com/siyuan-note/siyuan/issues/9202)
* [Virtual references exclude the name and aliases from the current document](https://github.com/siyuan-note/siyuan/issues/9204)
### Bugfix

View file

@ -29,6 +29,7 @@
* [改進刪除書籤提示](https://github.com/siyuan-note/siyuan/issues/9196)
* [改進創建快照和數據同步的穩定性](https://github.com/siyuan-note/siyuan/issues/9197)
* [自動將損壞的筆記本文件夾移動到 corrupted 文件夾下](https://github.com/siyuan-note/siyuan/issues/9202)
* [虛擬引用排除當前文檔命名和別名](https://github.com/siyuan-note/siyuan/issues/9204)
### 修復缺陷

View file

@ -29,6 +29,7 @@
* [改进删除书签提示](https://github.com/siyuan-note/siyuan/issues/9196)
* [改进创建快照和数据同步的稳定性](https://github.com/siyuan-note/siyuan/issues/9197)
* [自动将损坏的笔记本文件夹移动到 corrupted 文件夹下](https://github.com/siyuan-note/siyuan/issues/9202)
* [虚拟引用排除当前文档命名和别名](https://github.com/siyuan-note/siyuan/issues/9204)
### 修复缺陷

View file

@ -165,12 +165,21 @@ func CheckAuth(c *gin.Context) {
u, parseErr := url.Parse(origin)
if nil != parseErr {
logging.LogWarnf("parse origin [%s] failed: %s", origin, parseErr)
} else {
if !strings.HasPrefix(u.Host, util.LocalHost) && !strings.HasPrefix(u.Host, "[::1]") {
c.JSON(401, map[string]interface{}{"code": -1, "msg": "Auth failed"})
c.Abort()
return
}
c.JSON(401, map[string]interface{}{"code": -1, "msg": "Auth failed"})
c.Abort()
return
}
if "chrome-extension" == strings.ToLower(u.Scheme) {
c.Next()
return
}
if !strings.HasPrefix(u.Host, util.LocalHost) && !strings.HasPrefix(u.Host, "[::1]") {
c.JSON(401, map[string]interface{}{"code": -1, "msg": "Auth failed"})
c.Abort()
return
}
}

View file

@ -56,15 +56,15 @@ func getBlockVirtualRefKeywords(root *ast.Node) (ret []string) {
return ast.WalkContinue
})
content := buf.String()
ret = putBlockVirtualRefKeywords(content, root.ID, root.IALAttr("title"))
ret = putBlockVirtualRefKeywords(content, root)
return
}
ret = val.([]string)
return
}
func putBlockVirtualRefKeywords(blockContent, blockID, docTitle string) (ret []string) {
keywords := getVirtualRefKeywords(docTitle)
func putBlockVirtualRefKeywords(blockContent string, root *ast.Node) (ret []string) {
keywords := getVirtualRefKeywords(root)
if 1 > len(keywords) {
return
}
@ -94,7 +94,7 @@ func putBlockVirtualRefKeywords(blockContent, blockID, docTitle string) (ret []s
}
ret = gulu.Str.RemoveDuplicatedElem(ret)
virtualBlockRefCache.SetWithTTL(blockID, ret, 1, 10*time.Minute)
virtualBlockRefCache.SetWithTTL(root.ID, ret, 1, 10*time.Minute)
return
}
@ -174,7 +174,7 @@ func processVirtualRef(n *ast.Node, unlinks *[]*ast.Node, virtualBlockRefKeyword
return false
}
func getVirtualRefKeywords(docName string) (ret []string) {
func getVirtualRefKeywords(root *ast.Node) (ret []string) {
if !Conf.Editor.VirtualBlockRef {
return
}
@ -225,7 +225,18 @@ func getVirtualRefKeywords(docName string) (ret []string) {
}
// 虚拟引用排除当前文档名 https://github.com/siyuan-note/siyuan/issues/4537
ret = gulu.Str.ExcludeElem(ret, []string{docName})
// Virtual references exclude the name and aliases from the current document https://github.com/siyuan-note/siyuan/issues/9204
title := root.IALAttr("title")
ret = gulu.Str.ExcludeElem(ret, []string{title})
if name := root.IALAttr("name"); "" != name {
ret = gulu.Str.ExcludeElem(ret, []string{name})
}
if alias := root.IALAttr("alias"); "" != alias {
for _, a := range strings.Split(alias, ",") {
ret = gulu.Str.ExcludeElem(ret, []string{a})
}
}
ret = prepareMarkKeywords(ret)
return
}