image: prevent overwrite on copy

Signed-off-by: Varun Patil <varunpatil@ucla.edu>
pull/579/head
Varun Patil 2023-04-16 00:05:41 -07:00
parent e2408a5111
commit 7e88bc4248
1 changed files with 5 additions and 0 deletions

View File

@ -310,6 +310,11 @@ class ImageController extends GenericApiController
throw Exceptions::ForbiddenFileUpdate($file->getName()); throw Exceptions::ForbiddenFileUpdate($file->getName());
} }
// Check if target copy file exists
if ($copy && $file->getParent()->nodeExists($name)) {
throw Exceptions::ForbiddenFileUpdate($name);
}
// Check if we have imagick // Check if we have imagick
if (!class_exists('Imagick')) { if (!class_exists('Imagick')) {
throw Exceptions::Forbidden('Imagick extension is not available'); throw Exceptions::Forbidden('Imagick extension is not available');