Skip to content

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

:art: Do not validate file names when updating existing files https://github.com/siyuan-note/siyuan/issues/16536 (#16539)

Jeffrey Chencb58c643fce0
diff --git a/kernel/api/file.go b/kernel/api/file.go
index a6a49cbeeb..2ad297ee5f 100644
--- a/kernel/api/file.go
+++ b/kernel/api/file.go
@@ -380,10 +380,13 @@ func putFile(c *gin.Context) {
return
}
- if !util.IsValidUploadFileName(filepath.Base(fileAbsPath)) { // Improve kernel API `/api/file/putFile` parameter validation https://github.com/siyuan-note/siyuan/issues/14658
- ret.Code = http.StatusBadRequest
- ret.Msg = "invalid file path, please check https://github.com/siyuan-note/siyuan/issues/14658 for more details"
- return
+ fileExists := filelock.IsExist(fileAbsPath)
+ if !fileExists {
+ if !util.IsValidUploadFileName(filepath.Base(fileAbsPath)) { // Improve kernel API `/api/file/putFile` parameter validation https://github.com/siyuan-note/siyuan/issues/14658
+ ret.Code = http.StatusBadRequest
+ ret.Msg = "invalid file path, please check https://github.com/siyuan-note/siyuan/issues/14658 for more details"
+ return
+ }
}
isDirStr := c.PostForm("isDir")