Ver código fonte

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

master
JustAnotherArchivist 3 anos atrás
pai
commit
4d345a59df
1 arquivos alterados com 6 adições e 1 exclusões
  1. +6
    -1
      irclog.py

+ 6
- 1
irclog.py Ver arquivo

@@ -935,7 +935,12 @@ class WebServer:
# Process grep output with --with-filenames, --null, and --line-number into (path, line) tuples. # 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. # Lines are sorted by timestamp, filename, and line number to ensure a consistent and chronological order.
out = [] 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) fn, line = line.split('\0', 1)
assert fn.startswith(self.config['storage']['path'] + '/') and fn.count('/', len(self.config['storage']['path']) + 1) == 1 assert fn.startswith(self.config['storage']['path'] + '/') and fn.count('/', len(self.config['storage']['path']) + 1) == 1
_, path, _ = fn.rsplit('/', 2) _, path, _ = fn.rsplit('/', 2)


Carregando…
Cancelar
Salvar