From: Christian Heller Date: Thu, 25 Sep 2025 19:11:01 +0000 (+0200) Subject: For log file names, escape anything but the most boring characters. X-Git-Url: https://plomlompom.com/repos/?a=commitdiff_plain;h=50afc092fec7f00fdffa0c1e36464e75aa5bd1a8;p=ircplom For log file names, escape anything but the most boring characters. --- 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()