]> jfr.im git - uguu.git/commitdiff
fix bug with more then 2 dots v.1.6.7
authorGo Johansson (neku) <redacted>
Sat, 14 Jan 2023 02:02:55 +0000 (03:02 +0100)
committerGo Johansson (neku) <redacted>
Sat, 14 Jan 2023 02:02:55 +0000 (03:02 +0100)
package.json
src/Classes/Upload.php
src/config.json

index a54fbf150698be73e841c5ae65493ef80ae5e161..25459dbd387535959f2b8eddf5a57ac2f31d04f1 100644 (file)
@@ -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": {
index 79d7ab437b660277738fc51939808dce8a53ded0..e72f0df9d1a8f41d32d4189c27e1af4b8a832330 100644 (file)
@@ -48,7 +48,7 @@ class Upload extends Response
             $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),
@@ -251,7 +251,8 @@ class Upload extends Response
         return match ($dotCount) {
             0 => null,
             1 => end($extension),
-            2 => $this->doubleDotExtension($extension)
+            2 => $this->doubleDotExtension($extension),
+            default => end($extension)
         };
     }
 
@@ -278,6 +279,14 @@ class Upload extends Response
             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,
index da84c056f914f5c61a346931996a77d82b8cf483..b58a96ea200380b405f8ec7b2af8fcafdf23c076 100755 (executable)
@@ -3,7 +3,7 @@
     "allowErrors": false
   },
   "dest": "dist",
-  "pkgVersion": "1.6.6",
+  "pkgVersion": "1.6.7",
   "pages": [
     "index.ejs",
     "faq.ejs",