home · contact · privacy
For log file names, escape anything but the most boring characters.
authorChristian Heller <c.heller@plomlompom.de>
Thu, 25 Sep 2025 19:11:01 +0000 (21:11 +0200)
committerChristian Heller <c.heller@plomlompom.de>
Thu, 25 Sep 2025 19:11:01 +0000 (21:11 +0200)
src/ircplom/client_tui.py

index dbdd4985d3589d7da7b1d2abd8c705fa5fed0dc1..5413577a1a47424f486bb7f8b6016c08c17ccdec 100644 (file)
@@ -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()