1
0
Fork 0
forked from mia/0x0

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-w 2023-01-15 19:28:21 +01:00 committed by Jonas Wunderlich
parent e1e99957b6
commit 3950f6e8eb
No known key found for this signature in database
GPG key ID: 24CBC4B3DBFAAB90

View file

@ -247,8 +247,10 @@ class File(db.Model):
if not ext: if not ext:
if gmime in app.config["FHOST_EXT_OVERRIDE"]: if gmime in app.config["FHOST_EXT_OVERRIDE"]:
ext = app.config["FHOST_EXT_OVERRIDE"][gmime] ext = app.config["FHOST_EXT_OVERRIDE"][gmime]
elif guess:
ext = guess
else: else:
ext = guess_extension(gmime) ext = ""
return ext[:app.config["FHOST_MAX_EXT_LENGTH"]] or ".bin" return ext[:app.config["FHOST_MAX_EXT_LENGTH"]] or ".bin"