summaryrefslogtreecommitdiff
path: root/fhost.py
diff options
context:
space:
mode:
authorMia Herkt <mia@0x0.st>2022-12-01 01:19:05 +0100
committerMia Herkt <mia@0x0.st>2022-12-01 01:19:05 +0100
commit7661216bc00e072aec72a0047c867fbf90dbf9bf (patch)
tree68765cc86bafc79a7d50f9f2d29dd2135433b6c5 /fhost.py
parent9214bb483289cbcba8268654129e08d1369c4b24 (diff)
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
Diffstat (limited to 'fhost.py')
-rwxr-xr-xfhost.py2
1 files changed, 2 insertions, 0 deletions
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)