From 50afc092fec7f00fdffa0c1e36464e75aa5bd1a8 Mon Sep 17 00:00:00 2001 From: Christian Heller Date: Thu, 25 Sep 2025 21:11:01 +0200 Subject: [PATCH] For log file names, escape anything but the most boring characters. --- src/ircplom/client_tui.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/ircplom/client_tui.py b/src/ircplom/client_tui.py index dbdd498..5413577 100644 --- a/src/ircplom/client_tui.py +++ b/src/ircplom/client_tui.py @@ -45,7 +45,15 @@ class _ClientWindow(Window, ClientQueueMixin): def log(self, msg: str) -> None: super().log(msg) - ldir = _PATH_LOGS.joinpath(self._title) + escaped = '' + for char in self._title: + if (char.isalpha() and char.isascii()) or char in '-.': + escaped += char + else: + escaped += '_' + escaped += '.'.join(str(int(b)) for b in char.encode('utf8')) + escaped += '_' + ldir = _PATH_LOGS.joinpath(escaped) if not ldir.exists(): ldir.mkdir(parents=True) assert ldir.is_dir() -- 2.30.2