{"record":{"id":"d21750adeba9cd22","repo":"siyuan-note/siyuan","slug":"path-belongs-to-encrypted-notebook-s","errorCode":null,"errorMessage":"path belongs to encrypted notebook [%s]","messagePattern":"path belongs to encrypted notebook \\[(.+?)\\]","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/api/archive.go","lineNumber":41,"sourceCode":"\t\"io\"\n\t\"io/fs\"\n\t\"os\"\n\t\"path/filepath\"\n\t\"strings\"\n\t\"unicode/utf8\"\n\n\t\"github.com/88250/gulu\"\n\t\"github.com/gin-gonic/gin\"\n\t\"github.com/siyuan-note/logging\"\n\t\"github.com/siyuan-note/siyuan/kernel/model\"\n\t\"github.com/siyuan-note/siyuan/kernel/util\"\n\t\"golang.org/x/text/encoding/simplifiedchinese\"\n)\n\n// rejectEncryptedArchivePath 检查路径是否落入加密笔记本目录（含 symlink 绕过），是则返回错误。\nfunc rejectEncryptedArchivePath(absPath string) error {\n\tif boxID := model.EncryptedRawPathBoxID(absPath); boxID != \"\" {\n\t\treturn fmt.Errorf(\"path belongs to encrypted notebook [%s]\", boxID)\n\t}\n\tresolved, err := resolveArchivePath(absPath)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdataDir, err := resolveArchivePath(util.DataDir)\n\tif err != nil {\n\t\treturn err\n\t}\n\tif rel, relErr := filepath.Rel(dataDir, resolved); relErr == nil && filepath.IsLocal(rel) {\n\t\tif boxID := model.EncryptedRawPathBoxID(filepath.Join(util.DataDir, rel)); boxID != \"\" {\n\t\t\treturn fmt.Errorf(\"path belongs to encrypted notebook [%s]\", boxID)\n\t\t}\n\t}\n\treturn nil\n}\n\n// resolveArchivePath 解析最长已存在父路径的最终位置，包含 Windows 目录联接；解析失败时拒绝访问。","sourceCodeStart":23,"sourceCodeEnd":59,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/api/archive.go#L23-L59","documentation":"rejectEncryptedArchivePath checks whether an absolute archive path lands inside an encrypted notebook directory (including via symlink bypass) using model.EncryptedRawPathBoxID. The kernel refuses archive export/extract operations that would touch encrypted notebook raw files, so the operation is rejected with the owning notebook ID.","triggerScenarios":"Exporting/importing a workspace archive whose target path, after resolution, is inside a notebook's raw directory of an encrypted notebook.","commonSituations":"User selects a destination folder under data/<encrypted-notebook>/; a symlink in data/ points into an encrypted notebook directory; automated scripts staging archives inside the data dir.","solutions":["Choose an archive path outside any notebook directory (e.g. outside util.DataDir)","Remove the symlink pointing into the encrypted notebook directory","If you legitimately need the content, decrypt/export via supported UI flows instead of archive paths"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Go, before requesting the archive write\nif boxID := model.EncryptedRawPathBoxID(absPath); boxID != \"\" { return fmt.Errorf(\"choose another path, inside notebook %s\", boxID) }","typeGuard":null,"tryCatchPattern":"if err := exportArchive(p); err != nil && strings.Contains(err.Error(), \"encrypted notebook\") { promptUserForNewPath() }","preventionTips":["Keep archive/temp destinations outside the data directory","Avoid creating symlinks under the workspace data dir","Treat any path under data/<notebook-id>/ as off-limits for raw archives"],"tags":["archive","encrypted-notebook","path-safety"],"backgroundTag":"path-traversal-blocked","analyzedSha":"9f775e8a12daef8255556097396f9b2739078892","analyzedAt":"2026-09-19T03:17:15.984Z","contentChangedAt":"2026-09-19T03:17:15.984Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}