Fix handling double file name extensions

Long names would get truncated at the end, causing problems
including unresolvable file URLs. Example with default settings:
    .package.lst → .package.

Fixes #61
This commit is contained in:
Mia Herkt 2022-12-01 01:19:05 +01:00
parent 9214bb4832
commit 7661216bc0
Signed by: mia
GPG Key ID: 72E154B8622EC191
1 changed files with 2 additions and 0 deletions

View File

@ -218,6 +218,8 @@ class File(db.Model):
def get_ext(mime):
ext = "".join(Path(file_.filename).suffixes[-2:])
if len(ext) > app.config["FHOST_MAX_EXT_LENGTH"]:
ext = Path(file_.filename).suffixes[-1]
gmime = mime.split(";")[0]
guess = guess_extension(gmime)