修复在linux上使用错误分隔符的问题
*在debian 12上测试
This commit is contained in:
parent
75cac63b9b
commit
0e7088128c
@ -171,7 +171,7 @@ class HomeController extends Controller
|
|||||||
|
|
||||||
// 使用realpath函数解析路径,并检查解析后的路径是否在预期的目录中
|
// 使用realpath函数解析路径,并检查解析后的路径是否在预期的目录中
|
||||||
$realPath = realpath($absolutePath);
|
$realPath = realpath($absolutePath);
|
||||||
$dataDirectory = str_replace('/', '\\', Yii::getAlias(Yii::$app->params['dataDirectory']));
|
$dataDirectory = str_replace(['/', '\\'], DIRECTORY_SEPARATOR, Yii::getAlias(Yii::$app->params['dataDirectory']));
|
||||||
if (!$realPath || !str_starts_with($realPath, $dataDirectory)) {
|
if (!$realPath || !str_starts_with($realPath, $dataDirectory)) {
|
||||||
throw new NotFoundHttpException('File not found.');
|
throw new NotFoundHttpException('File not found.');
|
||||||
}
|
}
|
||||||
|
@ -157,7 +157,7 @@ class VaultController extends Controller
|
|||||||
|
|
||||||
// 使用realpath函数解析路径,并检查解析后的路径是否在预期的目录中
|
// 使用realpath函数解析路径,并检查解析后的路径是否在预期的目录中
|
||||||
$realPath = realpath($absolutePath);
|
$realPath = realpath($absolutePath);
|
||||||
$dataDirectory = str_replace('/', '\\', Yii::getAlias(Yii::$app->params['dataDirectory']));
|
$dataDirectory = str_replace(['/', '\\'], DIRECTORY_SEPARATOR, Yii::getAlias(Yii::$app->params['dataDirectory']));
|
||||||
if (!$realPath || !str_starts_with($realPath, $dataDirectory)) {
|
if (!$realPath || !str_starts_with($realPath, $dataDirectory)) {
|
||||||
throw new NotFoundHttpException('File not found.');
|
throw new NotFoundHttpException('File not found.');
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user