patch 6493c04f9d8bdb7b1d2c037fdd66c337a7a91af5 Author: E. Bosch Date: Sun May 31 00:26:34 CEST 2026 * utils: Modify sanitize_filename(): convert invalid chars to hex representation, this makes the filenames deterministic for the same session, and helps to not download a file more than once diff -rN -u old-irgramd/utils.py new-irgramd/utils.py --- old-irgramd/utils.py 2026-06-09 15:01:10.602118421 +0200 +++ new-irgramd/utils.py 2026-06-09 15:01:10.602118421 +0200 @@ -18,7 +18,7 @@ # Constants -FILENAME_INVALID_CHARS = re.compile('[/{}<>()"\'\\|&#%?]') +FILENAME_INVALID_CHARS = re.compile('[\0-\x1F/{}<>"\'\\|*&#%?\x7F]') SIMPLE_URL = re.compile('http(|s)://[^ ]+') from include import MAX_LINE @@ -87,12 +87,11 @@ return messages_limited def sanitize_filename(fn): - cn = str(sanitize_filename.cn) - new_fn, ns = FILENAME_INVALID_CHARS.subn(cn, fn) - if ns: - sanitize_filename.cn += 1 - return new_fn.strip('-').replace(' ','_') -sanitize_filename.cn = 0 + def hexize(m): + return '-{:x}-'.format(ord(m.group(0))) + + new_fn = FILENAME_INVALID_CHARS.sub(hexize, fn) + return new_fn.lstrip('-').replace(' ','_') def add_filename(filename, add): if add: