From 17921744313bcffeb65f9cd9fb387364691a39db Mon Sep 17 00:00:00 2001 From: Matt Singleton Date: Fri, 14 Jan 2022 18:56:56 -0600 Subject: HACK: assume all content is utf8 --- gemini.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/gemini.py b/gemini.py index cbc2eca..b940bb7 100644 --- a/gemini.py +++ b/gemini.py @@ -13,12 +13,13 @@ def htmlescape(text: str) -> str: def gem2html(gem: str) -> str: html = io.StringIO() - html.write('\n\n\n\n\n
') parser = fsm.Parser(gem.split('\n'), html) parser.parse() html.write('
\n\n') + print(html.getvalue()) return html.getvalue() @@ -76,7 +77,12 @@ def _get(url: str) -> dict: ssock.sendall('{url}\r\n'.format(url=url).encode('utf8')) fp = ssock.makefile(mode='rb') header = fp.readline(1027) - status, meta = header.decode('utf8').split(None, 1) + parts = header.decode('utf8').split(None, 1) + status = parts[0] + if len(parts) == 1: + meta = '' + else: + meta = parts[1] if status[0] != '2': return { 'status': status, -- cgit v1.2.3