Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:lock: Reject export savePath resolving into encrypted notebook directories #18034

Daniel26cf22735025
diff --git a/kernel/api/export.go b/kernel/api/export.go
index 257b482559..498a11adcf 100644
--- a/kernel/api/export.go
+++ b/kernel/api/export.go
@@ -575,6 +575,13 @@ func exportDocx(c *gin.Context) {
return
}
+ // savePath 由客户端指定,禁止写入加密笔记本目录(明文导出物会绕过加密、锁定后残留)
+ if rejectEncryptedBoxPath(savePath) {
+ ret.Code = -1
+ ret.Msg = model.Conf.Language(313)
+ return
+ }
+
fullPath, err := model.ExportDocx(id, savePath, removeAssets, merge)
if err != nil {
ret.Code = 1
@@ -622,6 +629,13 @@ func exportMdHTML(c *gin.Context) {
return
}
+ // savePath 由客户端指定,禁止写入加密笔记本目录(明文导出物会绕过加密、锁定后残留)
+ if rejectEncryptedBoxPath(savePath) {
+ ret.Code = -1
+ ret.Msg = model.Conf.Language(313)
+ return
+ }
+
name, content := model.ExportMarkdownHTML(id, savePath, false, false)
ret.Data = map[string]any{
"id": id,
@@ -825,6 +839,13 @@ func exportHTML(c *gin.Context) {
return
}
+ // savePath 由客户端指定,禁止写入加密笔记本目录(明文导出物会绕过加密、锁定后残留)
+ if rejectEncryptedBoxPath(savePath) {
+ ret.Code = -1
+ ret.Msg = model.Conf.Language(313)
+ return
+ }
+
name, content, _ := model.ExportHTML(id, savePath, pdf, keepFold, merge)
ret.Data = map[string]any{
"id": id,