summaryrefslogtreecommitdiff
path: root/fhost.py
diff options
context:
space:
mode:
authorjonas-w <git@03j.de>2023-01-15 19:28:21 +0100
committerJonas Wunderlich <git@jonas-wunderlich.de>2023-01-15 20:36:39 +0100
commit3950f6e8ebf264ff5fb7c4302f11667e41c0ce21 (patch)
treea1100d024ed707bb191dce669bc639cd8d45b777 /fhost.py
parente1e99957b6188cce657485f15ff3708fef9e5999 (diff)
fix 500 error when file extension could not be guessed
when a file without an extension was uploaded and the mimetypes.guess_extension returned None because there is no official file extension for that mimetype a NoneType was subscripted which yielded a 500 http error
Diffstat (limited to 'fhost.py')
-rwxr-xr-xfhost.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/fhost.py b/fhost.py
index a59e22e..4880f08 100755
--- a/fhost.py
+++ b/fhost.py
@@ -247,8 +247,10 @@ class File(db.Model):
if not ext:
if gmime in app.config["FHOST_EXT_OVERRIDE"]:
ext = app.config["FHOST_EXT_OVERRIDE"][gmime]
+ elif guess:
+ ext = guess
else:
- ext = guess_extension(gmime)
+ ext = ""
return ext[:app.config["FHOST_MAX_EXT_LENGTH"]] or ".bin"