From e1a75a5cedbef8a669c1156a681ce95096aacc5a Mon Sep 17 00:00:00 2001 From: Georg Lukas Date: Fri, 10 Dec 2021 14:45:14 +0100 Subject: Logger: jidstr is not a valid JID with MUC-PMs The logger often operates on filenames for log files and assumes that jid == filename, but MUC-PM filenames are `muc@domain\nick` (jidstr) instead of `muc@domain/nick` (jid) and the former is not a valid JID. This patch fixes the places where jid and jidstr are mixed up. --- poezio/logger.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/poezio/logger.py b/poezio/logger.py index 6e4a6ff0..9a901836 100644 --- a/poezio/logger.py +++ b/poezio/logger.py @@ -157,11 +157,11 @@ class Logger: def close(self, jid: str) -> None: """Close the log file for a JID.""" - jid = str(jid).replace('/', '\\') - if jid in self._fds: - self._fds[jid].close() + jidstr = str(jid).replace('/', '\\') + if jidstr in self._fds: + self._fds[jidstr].close() log.debug('Log file for %s closed.', jid) - del self._fds[jid] + del self._fds[jidstr] def reload_all(self) -> None: """Close and reload all the file handles (on SIGHUP)""" @@ -251,18 +251,18 @@ class Logger: :param force: Bypass the buffered fd check :returns: True if no error was encountered """ - jid = str(jid).replace('/', '\\') - if jid in self._fds.keys(): - fd = self._fds[jid] + jidstr = str(jid).replace('/', '\\') + if jidstr in self._fds.keys(): + fd = self._fds[jidstr] else: option_fd = self._check_and_create_log_dir(jid) if option_fd is None: return True fd = option_fd - filename = self.log_dir / jid + filename = self.log_dir / jidstr try: - if not force and self._busy_fds.get(jid): - self._buffered_fds[jid].append(logged_msg) + if not force and self._busy_fds.get(jidstr): + self._buffered_fds[jidstr].append(logged_msg) return True fd.write(logged_msg) except OSError: -- cgit v1.2.3