function CKEditor5ImageController::prepareFilename

Prepares the filename to strip out any malicious extensions.

Parameters

string $filename: The file name.

array $validators: The array of upload validators.

Return value

string The prepared/munged filename.

1 call to CKEditor5ImageController::prepareFilename()
CKEditor5ImageController::upload in core/modules/ckeditor5/src/Controller/CKEditor5ImageController.php
Uploads and saves an image from a CKEditor 5 POST.

File

core/modules/ckeditor5/src/Controller/CKEditor5ImageController.php, line 276

Class

CKEditor5ImageController
Returns response for CKEditor 5 Simple image upload adapter.

Namespace

Drupal\ckeditor5\Controller

Code

protected function prepareFilename($filename, array &$validators) {
    $extensions = $validators['file_validate_extensions'][0] ?? '';
    $event = new FileUploadSanitizeNameEvent($filename, $extensions);
    $this->eventDispatcher
        ->dispatch($event);
    return $event->getFilename();
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.