From 7661216bc00e072aec72a0047c867fbf90dbf9bf Mon Sep 17 00:00:00 2001 From: Mia Herkt Date: Thu, 1 Dec 2022 01:19:05 +0100 Subject: [PATCH] Fix handling double file name extensions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Long names would get truncated at the end, causing problems including unresolvable file URLs. Example with default settings: .package.lst → .package. Fixes #61 --- fhost.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fhost.py b/fhost.py index 026e3bd..70e1109 100755 --- a/fhost.py +++ b/fhost.py @@ -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)