From 21aabc216d5af93f267b9641e8207d50a21375b9 Mon Sep 17 00:00:00 2001 From: Daniel <845765@qq.com> Date: Sun, 17 Sep 2023 11:15:12 +0800 Subject: [PATCH 1/3] :art: Virtual references exclude the name and aliases from the current document https://github.com/siyuan-note/siyuan/issues/9204 --- kernel/model/virutalref.go | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/kernel/model/virutalref.go b/kernel/model/virutalref.go index bda7bda4e..7b2718e8c 100644 --- a/kernel/model/virutalref.go +++ b/kernel/model/virutalref.go @@ -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 } From 5e21b218b600eeb3b6b9b689ef38f2978be35033 Mon Sep 17 00:00:00 2001 From: Daniel <845765@qq.com> Date: Sun, 17 Sep 2023 11:16:32 +0800 Subject: [PATCH 2/3] :art: Virtual references exclude the name and aliases from the current document https://github.com/siyuan-note/siyuan/issues/9204 --- app/changelogs/v2.10.6/v2.10.6.md | 1 + app/changelogs/v2.10.6/v2.10.6_zh_CHT.md | 1 + app/changelogs/v2.10.6/v2.10.6_zh_CN.md | 1 + 3 files changed, 3 insertions(+) diff --git a/app/changelogs/v2.10.6/v2.10.6.md b/app/changelogs/v2.10.6/v2.10.6.md index ce6badf39..9b6664300 100644 --- a/app/changelogs/v2.10.6/v2.10.6.md +++ b/app/changelogs/v2.10.6/v2.10.6.md @@ -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 diff --git a/app/changelogs/v2.10.6/v2.10.6_zh_CHT.md b/app/changelogs/v2.10.6/v2.10.6_zh_CHT.md index bdb576e72..3af95d29f 100644 --- a/app/changelogs/v2.10.6/v2.10.6_zh_CHT.md +++ b/app/changelogs/v2.10.6/v2.10.6_zh_CHT.md @@ -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) ### 修復缺陷 diff --git a/app/changelogs/v2.10.6/v2.10.6_zh_CN.md b/app/changelogs/v2.10.6/v2.10.6_zh_CN.md index ef50a7b21..4995c1c29 100644 --- a/app/changelogs/v2.10.6/v2.10.6_zh_CN.md +++ b/app/changelogs/v2.10.6/v2.10.6_zh_CN.md @@ -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) ### 修复缺陷 From 0e7dcc0ea19cd1e08a72ff8d9c74a954ee824c99 Mon Sep 17 00:00:00 2001 From: Daniel <845765@qq.com> Date: Sun, 17 Sep 2023 20:45:21 +0800 Subject: [PATCH 3/3] :art: Authenticate requests with the Origin header other than 127.0.0.1 https://github.com/siyuan-note/siyuan/issues/9180 --- kernel/model/session.go | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/kernel/model/session.go b/kernel/model/session.go index 089d89b32..04dbd9ccc 100644 --- a/kernel/model/session.go +++ b/kernel/model/session.go @@ -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 } }