mirror of
https://github.com/whyour/qinglong.git
synced 2026-07-01 04:40:38 +08:00
修复文件越权访问
This commit is contained in:
@@ -65,11 +65,13 @@ export default class ScriptService {
|
||||
}
|
||||
|
||||
public async getFile(filePath: string, fileName: string) {
|
||||
let _filePath = join(config.scriptPath, filePath, fileName);
|
||||
if (filePath.startsWith(config.dataPath)) {
|
||||
_filePath = join(filePath, fileName);
|
||||
const finalPath = path.resolve(config.scriptPath, filePath, fileName);
|
||||
|
||||
if (!finalPath.startsWith(config.scriptPath)) {
|
||||
return '';
|
||||
}
|
||||
const content = await getFileContentByName(_filePath);
|
||||
|
||||
const content = await getFileContentByName(finalPath);
|
||||
return content;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user