Skip to content

Commit

Permalink
fix bug with more then 2 dots
Browse files Browse the repository at this point in the history
  • Loading branch information
nokonoko committed Jan 14, 2023
1 parent 8806631 commit 4246ded
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"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.",
"homepage": "https://uguu.se",
"repository": {
Expand Down
13 changes: 11 additions & 2 deletions src/Classes/Upload.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function reFiles(array $files): array
$hash = sha1_file($file['tmp_name']);
$this->FILE_INFO = [
'TEMP_NAME' => $file['tmp_name'],
'NAME' => strip_tags($file['name']),
'NAME' => strip_tags($this->checkNameLength($file['name'])),
'SIZE' => $file['size'],
'SHA1' => $hash,
'EXTENSION' => $this->fileExtension($file),
Expand Down Expand Up @@ -251,7 +251,8 @@ public function fileExtension(array $file): string
return match ($dotCount) {
0 => null,
1 => end($extension),
2 => $this->doubleDotExtension($extension)
2 => $this->doubleDotExtension($extension),
default => end($extension)
};
}

Expand All @@ -278,6 +279,14 @@ public function checkExtensionBlacklist(): void
throw new Exception('Filetype not allowed.', 415);
}
}

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,
Expand Down
2 changes: 1 addition & 1 deletion src/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"allowErrors": false
},
"dest": "dist",
"pkgVersion": "1.6.6",
"pkgVersion": "1.6.7",
"pages": [
"index.ejs",
"faq.ejs",
Expand Down

0 comments on commit 4246ded

Please # to comment.