An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:lock: https://github.com/siyuan-note/siyuan/security/advisories/GHSA-rx4h-526q-4458
Daniela1d2d0f1b02f
diff --git a/kernel/go.mod b/kernel/go.modindex ff9560b840..c3f0776cdf 100644--- a/kernel/go.mod+++ b/kernel/go.mod@@ -49,6 +49,7 @@ require (github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51github.com/klippa-app/go-pdfium v1.17.2github.com/mattn/go-sqlite3 v2.0.3+incompatible+ github.com/microcosm-cc/bluemonday v1.0.27github.com/mitchellh/go-ps v1.0.0github.com/mssola/useragent v1.0.0github.com/olahol/melody v1.4.0@@ -119,6 +120,7 @@ require (github.com/aws/aws-sdk-go-v2/service/ssooidc v1.35.17 // indirectgithub.com/aws/aws-sdk-go-v2/service/sts v1.41.9 // indirectgithub.com/aws/smithy-go v1.24.2 // indirect+ github.com/aymerick/douceur v0.2.0 // indirectgithub.com/bytedance/gopkg v0.1.3 // indirectgithub.com/bytedance/sonic v1.14.1 // indirectgithub.com/bytedance/sonic/loader v0.3.0 // indirectdiff --git a/kernel/go.sum b/kernel/go.sumindex c74914938b..7de58b5af8 100644--- a/kernel/go.sum+++ b/kernel/go.sum@@ -93,6 +93,8 @@ github.com/aws/aws-sdk-go-v2/service/sts v1.41.9 h1:Cng+OOwCHmFljXIxpEVXAGMnBia8github.com/aws/aws-sdk-go-v2/service/sts v1.41.9/go.mod h1:LrlIndBDdjA/EeXeyNBle+gyCwTlizzW5ycgWnvIxkk=github.com/aws/smithy-go v1.24.2 h1:FzA3bu/nt/vDvmnkg+R8Xl46gmzEDam6mZ1hzmwXFng=github.com/aws/smithy-go v1.24.2/go.mod h1:YE2RhdIuDbA5E5bTdciG9KrW3+TiEONeUWCqxX9i1Fc=+github.com/aymerick/douceur v0.2.0 h1:Mv+mAeH1Q+n9Fr+oyamOlAkUNPWPlA8PPGR0QAaYuPk=+github.com/aymerick/douceur v0.2.0/go.mod h1:wlT5vV2O3h55X9m7iVYN0TBM0NH/MmbLnd30/FjWUq4=github.com/bytedance/gopkg v0.1.3 h1:TPBSwH8RsouGCBcMBktLt1AymVo2TVsBVCY4b6TnZ/M=github.com/bytedance/gopkg v0.1.3/go.mod h1:576VvJ+eJgyCzdjS+c4+77QF3p7ubbtiKARP3TxducM=github.com/bytedance/sonic v1.14.1 h1:FBMC0zVz5XUmE4z9wF4Jey0An5FueFvOsTKKKtwIl7w=@@ -285,6 +287,8 @@ github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+mgithub.com/mattn/go-runewidth v0.0.10/go.mod h1:RAqKPSqVFrSLVXbA8x7dzmKdmGzieGRCM46jaSJTDAk=github.com/mattn/go-runewidth v0.0.19 h1:v++JhqYnZuu5jSKrk9RbgF5v4CGUjqRfBm05byFGLdw=github.com/mattn/go-runewidth v0.0.19/go.mod h1:XBkDxAl56ILZc9knddidhrOlY5R/pDhgLpndooCuJAs=+github.com/microcosm-cc/bluemonday v1.0.27 h1:MpEUotklkwCSLeH+Qdx1VJgNqLlpY2KXwXFM08ygZfk=+github.com/microcosm-cc/bluemonday v1.0.27/go.mod h1:jFi9vgW+H7c3V0lb6nR74Ib/DIB5OBs92Dimizgw2cA=github.com/mitchellh/copystructure v1.2.0 h1:vpKXTN4ewci03Vljg/q9QvCGUDttBOGBIa15WveJJGw=github.com/mitchellh/copystructure v1.2.0/go.mod h1:qLl+cE2AmVv+CoeAwDPye/v+N2HKCj9FbZEVFJRxO9s=github.com/mitchellh/go-ps v1.0.0 h1:i6ampVEEF4wQFF+bkYfwYgY+F/uYJDktmvLPf7qIgjc=diff --git a/kernel/sql/av_gallery.go b/kernel/sql/av_gallery.goindex 1cecd00990..25137baebb 100644--- a/kernel/sql/av_gallery.go+++ b/kernel/sql/av_gallery.go@@ -204,6 +204,8 @@ func fillAttributeViewGalleryCardCover(attrView *av.AttributeView, view *av.View}for _, asset := range assetValue.MAsset {+ asset.Content = util.SanitizeImgSrc(asset.Content)+if asset.Type == av.AssetTypeImage && util.IsPossiblyImage(asset.Content) {galleryCard.CoverURL = asset.Contentbreakdiff --git a/kernel/sql/av_kanban.go b/kernel/sql/av_kanban.goindex 46f96c6976..4f105480be 100644--- a/kernel/sql/av_kanban.go+++ b/kernel/sql/av_kanban.go@@ -199,6 +199,8 @@ func fillAttributeViewKanbanCardCover(attrView *av.AttributeView, view *av.View,}for _, asset := range assetValue.MAsset {+ asset.Content = util.SanitizeImgSrc(asset.Content)+if asset.Type == av.AssetTypeImage && util.IsPossiblyImage(asset.Content) {kanbanCard.CoverURL = asset.Contentbreakdiff --git a/kernel/util/misc.go b/kernel/util/misc.goindex a484b7001e..40e03e50e9 100644--- a/kernel/util/misc.go+++ b/kernel/util/misc.go@@ -26,6 +26,7 @@ import ("unicode""github.com/88250/lute/html"+ "github.com/microcosm-cc/bluemonday""github.com/siyuan-note/logging")@@ -211,6 +212,20 @@ func GetContainsSubStrs(s string, subStrs []string) (ret []string) {return}+func SanitizeImgSrc(src string) string {+ if strings.HasPrefix(src, "assets/") {+ src = "http://127.0.0.1:6806/" + src+ }++ src = strings.TrimSpace(src)+ h := "<img src=\"" + src + "\">"+ p := bluemonday.UGCPolicy()+ ret := p.Sanitize(h)+ ret = strings.TrimPrefix(ret, "<img src=\"")+ ret = strings.TrimSuffix(ret, "\">")+ return ret+}+func SanitizeSVG(svgInput string) string {// 1. 将字符串解析为节点树doc, err := html.Parse(strings.NewReader(svgInput))