From 453beff09dee8773f46605ea9ed8aeaf14f7c000 Mon Sep 17 00:00:00 2001 From: Zed Date: Mon, 21 Oct 2019 08:31:02 +0200 Subject: [PATCH] Fix wrong png mimetypes --- src/utils.nim | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/utils.nim b/src/utils.nim index 23b8797..3c2167b 100644 --- a/src/utils.nim +++ b/src/utils.nim @@ -10,7 +10,8 @@ const "pbs.twimg.com", "video.twimg.com" ] - badExts = @["1500x500", "jpgn", "jpg:", "jpg_"] + badJpgExts = @["1500x500", "jpgn", "jpg:", "jpg_"] + badPngExts = @["pngn", "png:", "png_"] proc getHmac*(data: string): string = ($hmac(sha256, key, data))[0 .. 12] @@ -30,8 +31,10 @@ proc getPicUrl*(link: string): string = proc cleanFilename*(filename: string): string = const reg = re"[^A-Za-z0-9._-]" result = filename.replace(reg, "_") - if badExts.anyIt(it in result): + if badJpgExts.anyIt(it in result): result &= ".jpg" + elif badPngExts.anyIt(it in result): + result &= ".png" proc filterParams*(params: Table): seq[(string, string)] = let filter = ["name", "id", "list", "referer"]