aboutsummaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorGravatar jesopo2020-01-30 17:12:57 +0000
committerGravatar jesopo2020-01-30 17:12:57 +0000
commit53c6cc85382e2bed3281a95590af85e2e0642179 (patch)
tree60423895427e6342a5ff608548b74bfa04541256 /modules
parentallow !msearch to work in PM (diff)
signature
replace "/" in channel logfile names with ","
Diffstat (limited to 'modules')
-rw-r--r--modules/channel_log.py8
1 files changed, 7 insertions, 1 deletions
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: