소스 검색

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

master
JustAnotherArchivist 3 년 전
부모
커밋
4d345a59df
1개의 변경된 파일6개의 추가작업 그리고 1개의 파일을 삭제
  1. +6
    -1
      irclog.py

+ 6
- 1
irclog.py 파일 보기

@@ -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)


불러오는 중...
취소
저장