Browse Source

Fix splitting on various things other than LF causing exceptions in the grep output handling

master
JustAnotherArchivist 3 years ago
parent
commit
4d345a59df
1 changed files with 6 additions and 1 deletions
  1. +6
    -1
      irclog.py

+ 6
- 1
irclog.py View File

@@ -935,7 +935,12 @@ class WebServer:
# 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():
# splitlines splits on more than desired, in particular also on various things that can occur within IRC messages (which is really anything except CR LF, basically).
# split has the downside of producing a final empty element (because stdout ends with LF) and an empty element when the input is empty.
# So just discard empty lines.
for line in stdout.decode('utf-8').split('\n'):
if line == '':
continue
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)


Loading…
Cancel
Save