Improve asset file path handling when moving assets

This commit is contained in:
Luke Towers 2020-03-31 04:09:18 -06:00
parent 2b8939cc8b
commit 6711dae8ef
1 changed files with 8 additions and 1 deletions

View File

@ -333,13 +333,20 @@ class AssetList extends WidgetBase
$basename = basename($path);
$originalFullPath = $this->getFullPath($path);
$newFullPath = rtrim($destinationFullPath, '/').'/'.$basename;
$newFullPath = realpath(rtrim($destinationFullPath, '/')) . '/' . $basename;
$safeDir = $this->getAssetsPath();
if ($originalFullPath == $newFullPath) {
continue;
}
if (!starts_with($newFullPath, $safeDir)) {
throw new ApplicationException(Lang::get(
'cms::lang.asset.error_moving_file',
['file' => $basename]
));
}
if (is_file($originalFullPath)) {
if (!@File::move($originalFullPath, $newFullPath)) {
throw new ApplicationException(Lang::get(