1
0
mirror of https://github.com/nokonoko/Uguu.git synced 2024-01-06 13:35:15 +00:00

fix bug with more then 2 dots

This commit is contained in:
Go Johansson (neku) 2023-01-14 03:02:55 +01:00
parent 88066317e5
commit 4246dedebe
3 changed files with 13 additions and 4 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "uguu", "name": "uguu",
"version": "1.6.6", "version": "1.6.7",
"description": "Uguu is a simple lightweight temporary file host with support for drop, paste, click and API uploading.", "description": "Uguu is a simple lightweight temporary file host with support for drop, paste, click and API uploading.",
"homepage": "https://uguu.se", "homepage": "https://uguu.se",
"repository": { "repository": {

View File

@ -48,7 +48,7 @@ class Upload extends Response
$hash = sha1_file($file['tmp_name']); $hash = sha1_file($file['tmp_name']);
$this->FILE_INFO = [ $this->FILE_INFO = [
'TEMP_NAME' => $file['tmp_name'], 'TEMP_NAME' => $file['tmp_name'],
'NAME' => strip_tags($file['name']), 'NAME' => strip_tags($this->checkNameLength($file['name'])),
'SIZE' => $file['size'], 'SIZE' => $file['size'],
'SHA1' => $hash, 'SHA1' => $hash,
'EXTENSION' => $this->fileExtension($file), 'EXTENSION' => $this->fileExtension($file),
@ -251,7 +251,8 @@ class Upload extends Response
return match ($dotCount) { return match ($dotCount) {
0 => null, 0 => null,
1 => end($extension), 1 => end($extension),
2 => $this->doubleDotExtension($extension) 2 => $this->doubleDotExtension($extension),
default => end($extension)
}; };
} }
@ -279,6 +280,14 @@ class Upload extends Response
} }
} }
public function checkNameLength(string $fileName): string {
if (strlen($fileName) > 250) {
return substr($fileName, 0, 250);
} else {
return $fileName;
}
}
/** /**
* Generates a random string of characters, checks if it exists in the database, * Generates a random string of characters, checks if it exists in the database,
* and if it does, it generates another one * and if it does, it generates another one

View File

@ -3,7 +3,7 @@
"allowErrors": false "allowErrors": false
}, },
"dest": "dist", "dest": "dist",
"pkgVersion": "1.6.6", "pkgVersion": "1.6.7",
"pages": [ "pages": [
"index.ejs", "index.ejs",
"faq.ejs", "faq.ejs",