Upgrade to 3.5

This commit is contained in:
Bastian Allgeier
2020-12-15 11:01:41 +01:00
parent eabce32cf0
commit 9109130c9c
43 changed files with 306 additions and 159 deletions

View File

@@ -202,15 +202,23 @@ class FileRules
* Validates the extension, MIME type and filename
*
* @param \Kirby\Cms\File $file
* @param string|null $mime If not passed, the MIME type is detected from the file
* @param string|null|false $mime If not passed, the MIME type is detected from the file,
* if `false`, the MIME type is not validated for performance reasons
* @return bool
* @throws \Kirby\Exception\InvalidArgumentException If the extension, MIME type or filename is missing or forbidden
*/
public static function validFile(File $file, ?string $mime = null): bool
public static function validFile(File $file, $mime = null): bool
{
if ($mime === false) {
// request to skip the MIME check for performance reasons
$validMime = true;
} else {
$validMime = static::validMime($file, $mime ?? $file->mime());
}
return
$validMime &&
static::validExtension($file, $file->extension()) &&
static::validMime($file, $mime ?? $file->mime()) &&
static::validFilename($file, $file->filename());
}