From 3950f6e8ebf264ff5fb7c4302f11667e41c0ce21 Mon Sep 17 00:00:00 2001 From: jonas-w Date: Sun, 15 Jan 2023 19:28:21 +0100 Subject: [PATCH] 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 --- fhost.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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"