diff --git a/copyparty/ico.py b/copyparty/ico.py index c149397d..820c53af 100644 --- a/copyparty/ico.py +++ b/copyparty/ico.py @@ -94,10 +94,21 @@ class Ico(object): -{} """ - svg = svg.format(h, c[:6], c[6:], html_escape(ext, True)) + + txt = html_escape(ext, True) + if "\n" in txt: + lines = txt.split("\n") + n = len(lines) + y = "20%" if n == 2 else "10%" if n == 3 else "0" + zs = '%s' + txt = "".join([zs % (x,) for x in lines]) + else: + y = "50%" + + svg = svg.format(h, c[:6], y, c[6:], txt) return "image/svg+xml", svg.encode("utf-8") diff --git a/copyparty/th_srv.py b/copyparty/th_srv.py index 206592ee..dc07556f 100644 --- a/copyparty/th_srv.py +++ b/copyparty/th_srv.py @@ -4,6 +4,7 @@ from __future__ import print_function, unicode_literals import hashlib import logging import os +import re import shutil import subprocess as sp import threading @@ -49,6 +50,9 @@ HAVE_WEBP = False EXTS_TH = set(["jpg", "webp", "png"]) EXTS_AC = set(["opus", "owa", "caf", "mp3"]) +PTN_TS = re.compile("^-?[0-9a-f]{8,10}$") + + try: if os.environ.get("PRTY_NO_PIL"): raise Exception() @@ -998,6 +1002,8 @@ class ThumbSrv(object): # thumb file try: b64, ts, ext = f.split(".") + if len(ts) > 8 and PTN_TS.match(ts): + ts = "yeahokay" if len(b64) != 24 or len(ts) != 8 or ext not in exts: raise Exception() except: