diff --git a/irclog.py b/irclog.py index 96b1403..7798c95 100644 --- a/irclog.py +++ b/irclog.py @@ -877,12 +877,14 @@ class WebServer: yield (path, line) def _stdout_with_path(self, stdout): - # Process grep output with --with-filenames, --null, and --line-number into (path, line) tuples; this blindly assumes the expected directory structure of '.../path/YYYY-MM.log'. + # Process grep output with --with-filenames, --null, and --line-number into (path, line) tuples. # Lines are sorted by timestamp, filename, and line number to ensure a consistent and chronological order. out = [] for line in stdout.decode('utf-8').splitlines(): fn, line = line.split('\0', 1) + assert fn.startswith(self.config['storage']['path'] + '/') and fn.count('/', len(self.config['storage']['path']) + 1) == 1 _, path, _ = fn.rsplit('/', 2) + assert path in self._paths ln, line = line.split(':', 1) ln = int(ln) ts = float(line.split(' ', 1)[0])