Improve asset file path handling when moving assets
This commit is contained in:
parent
2b8939cc8b
commit
6711dae8ef
|
|
@ -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(
|
||||
|
|
|
|||
Loading…
Reference in New Issue