# Open fn, iterate over its lines yielding (path, line) tuples
try:
with open(fn, 'r') as fp:
with open(fn, 'r', errors = 'surrogateescape') as fp:
for line in fp:
yield (path, line)
except FileNotFoundError:
@@ -960,7 +960,7 @@ class WebServer:
# 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'):
for line in stdout.decode('utf-8', errors = 'surrogateescape').split('\n'):
if line == '':
continue
fn, line = line.split('\0', 1)
@@ -995,7 +995,7 @@ class WebServer:
command = 'UNKNOWN'
d = datetime.datetime.utcfromtimestamp(ts).replace(tzinfo = datetime.timezone.utc)
f'<head><title>{html.escape(self._paths[request.match_info["path"]][0])} log for {date:%Y-%m-%d}</title>{self.generalStyleTag}{self.logStyleTag}</head>',