fix(import): harden directory import path handling

This commit is contained in:
digua committed 2026-05-21 22:26:55 +08:00
1 parent 56902fea1c
commit 5db4b3bf9d
2 files changed
+15 -6

No files matched your search

+2 -1
View File
@@ -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)
}