init
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Esun\FileManager\Model;
|
||||
|
||||
use Magento\Framework\File\Uploader;
|
||||
|
||||
class FileUploader extends Uploader
|
||||
{
|
||||
/**
|
||||
* Preserve safe Unicode file names prepared by Filename.
|
||||
*
|
||||
* @param string|null $fileName
|
||||
* @return string
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
public static function getCorrectFileName($fileName)
|
||||
{
|
||||
$fileName = is_string($fileName) ? ltrim($fileName, '.') : '';
|
||||
if ($fileName === '' || strlen($fileName) > 255
|
||||
|| !preg_match('/^[\p{L}\p{N}._-]+\.[a-z0-9]+$/u', $fileName)
|
||||
|| str_contains($fileName, '..')
|
||||
) {
|
||||
throw new \InvalidArgumentException((string) __('The generated file name is invalid.'));
|
||||
}
|
||||
|
||||
return $fileName;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user