mirror of
https://github.com/hellodigua/ChatLab.git
synced 2026-10-26 02:04:37 +08:00
fix(import): harden directory import path handling
This commit is contained in:
1 parent
56902fea1c
commit
5db4b3bf9d
2 files changed
+15
-6
No files matched your search
@@ -164,7 +164,8 @@ export function registerImportRoutes(server: FastifyInstance, dbManager: Databas
|
||||
if (segments.length > 1) {
|
||||
relPath = segments.slice(1).join('/')
|
||||
}
|
||||
const targetPath = path.join(tmpDir, relPath)
|
||||
const targetPath = path.resolve(tmpDir, relPath)
|
||||
if (!targetPath.startsWith(tmpDir + path.sep)) continue
|
||||
fs.mkdirSync(path.dirname(targetPath), { recursive: true })
|
||||
fs.writeFileSync(targetPath, fileBuffers[i].data)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user