From 53c6cc85382e2bed3281a95590af85e2e0642179 Mon Sep 17 00:00:00 2001 From: jesopo Date: Thu, 30 Jan 2020 17:12:57 +0000 Subject: replace "/" in channel logfile names with "," --- modules/channel_log.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'modules') diff --git a/modules/channel_log.py b/modules/channel_log.py index 0239ba1d..5f57a439 100644 --- a/modules/channel_log.py +++ b/modules/channel_log.py @@ -17,7 +17,13 @@ class Module(ModuleManager.BaseModule): server.get_setting("channel-log", self.bot.get_setting("channel-log", False))) def _file(self, server_name, channel_name): - return self.data_directory("%s/%s.log" % (server_name, channel_name)) + # if a channel name has os.path.sep (e.g. "/") in it, the channel's log + # file will create a subdirectory. + # + # to avoid this, we'll replace os.path.sep with "," (0x2C) as it is + # forbidden in channel names. + sanitised_name = channel_name.replace(os.path.sep, ",") + return self.data_directory("%s/%s.log" % (server_name, sanitised_name)) def _log(self, server, channel, line): if self._enabled(server, channel): with open(self._file(str(server), str(channel)), "a") as log: -- cgit v1.3.1-10-gc9f91