Fix wrong png mimetypes

This commit is contained in:
Zed 2019-10-21 08:31:02 +02:00
parent ea4a8cab2f
commit 453beff09d

View file

@ -10,7 +10,8 @@ const
"pbs.twimg.com", "pbs.twimg.com",
"video.twimg.com" "video.twimg.com"
] ]
badExts = @["1500x500", "jpgn", "jpg:", "jpg_"] badJpgExts = @["1500x500", "jpgn", "jpg:", "jpg_"]
badPngExts = @["pngn", "png:", "png_"]
proc getHmac*(data: string): string = proc getHmac*(data: string): string =
($hmac(sha256, key, data))[0 .. 12] ($hmac(sha256, key, data))[0 .. 12]
@ -30,8 +31,10 @@ proc getPicUrl*(link: string): string =
proc cleanFilename*(filename: string): string = proc cleanFilename*(filename: string): string =
const reg = re"[^A-Za-z0-9._-]" const reg = re"[^A-Za-z0-9._-]"
result = filename.replace(reg, "_") result = filename.replace(reg, "_")
if badExts.anyIt(it in result): if badJpgExts.anyIt(it in result):
result &= ".jpg" result &= ".jpg"
elif badPngExts.anyIt(it in result):
result &= ".png"
proc filterParams*(params: Table): seq[(string, string)] = proc filterParams*(params: Table): seq[(string, string)] =
let filter = ["name", "id", "list", "referer"] let filter = ["name", "id", "list", "referer"]