diff --git a/core/modules/ckeditor5/src/Controller/CKEditor5ImageController.php b/core/modules/ckeditor5/src/Controller/CKEditor5ImageController.php index 4492f4ec99450f4f19aefe5a8142191366809a42..b07ef54b59d781a38c953d601f19440ecbda63d4 100644 --- a/core/modules/ckeditor5/src/Controller/CKEditor5ImageController.php +++ b/core/modules/ckeditor5/src/Controller/CKEditor5ImageController.php @@ -82,8 +82,11 @@ public static function create(ContainerInterface $container) { */ public function upload(Request $request): Response { // Getting the UploadedFile directly from the request. - /** @var \Symfony\Component\HttpFoundation\File\UploadedFile $upload */ + /** @var \Symfony\Component\HttpFoundation\File\UploadedFile|null $upload */ $upload = $request->files->get('upload'); + if ($upload === NULL || !$upload->isValid()) { + throw new HttpException(500, $upload?->getErrorMessage() ?: 'Invalid file upload'); + } $filename = $upload->getClientOriginalName(); /** @var \Drupal\editor\EditorInterface $editor */