Merge pull request #85 from gojohansson/patch-2

Update Upload.php
pull/89/head
Go Johansson (neku) 2023-05-13 01:10:30 +02:00 committed by GitHub
commit 2002a49442
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 5 deletions

View File

@ -247,17 +247,19 @@
*
* @return string The file extension of the file.
*/
public function fileExtension(array $file):string
public function fileExtension(array $file):?string
{
if(str_contains($file['name'], '.')){
$extension = explode('.', $file['name']);
$dotCount = substr_count($file['name'], '.');
return match ($dotCount) {
0 => null,
1 => end($extension),
2 => $this->doubleDotExtension($extension),
default => end($extension)
};
}
return "NOEXT";
}
/**
* > Check if the file's MIME type is in the blacklist
@ -309,7 +311,7 @@
$index = rand(0, strlen($this->Connector->CONFIG['ID_CHARSET']) - 1);
$NEW_NAME .= $this->Connector->CONFIG['ID_CHARSET'][$index];
}
if (!empty($extension)) {
if ($extension != "NOEXT") {
$NEW_NAME .= '.' . $extension;
}
} while ($this->Connector->dbCheckNameExists($NEW_NAME));