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
This commit is contained in:
Jonas Wunderlich 2023-01-15 19:28:21 +01:00 committed by Jonas Wunderlich
parent e1e99957b6
commit 3950f6e8eb
Signed by: jonas-w
GPG Key ID: 24CBC4B3DBFAAB90
1 changed files with 3 additions and 1 deletions

View File

@ -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"