=> 0d96ccf7639343b579d17ae597114c3a61cadac4
[1mdiff --git a/gmcapsule/__init__.py b/gmcapsule/__init__.py[m [1mindex 81a2452..e3e3763 100644[m [1m--- a/gmcapsule/__init__.py[m [1m+++ b/gmcapsule/__init__.py[m [36m@@ -36,7 +36,7 @@[m [mclass Config:[m return Path(self.ini.get('server', 'certs', fallback='.certs'))[m [m def root_dir(self):[m [31m- return Path(self.ini.get('server', 'root', fallback='.'))[m [32m+[m[32m return Path(self.ini.get('server', 'root', fallback='.')).resolve()[m [m def mod_dirs(self):[m return [Path(p).resolve() for p in shlex.split(self.ini.get('server', 'modules', fallback='.'))][m [36m@@ -124,10 +124,10 @@[m [mdef get_mime_type(path):[m if lp.endswith('.md') or lp.endswith('.markdown') or lp.endswith('.mdown'):[m return 'text/markdown'[m [m [31m- if not path.exists():[m [32m+[m[32m if not Path(p).exists():[m return None[m [m [31m- mt = mimetypes.guess_type(path)[0][m [32m+[m[32m mt = mimetypes.guess_type(p)[0][m if mt is not None:[m return mt[m [m [1mdiff --git a/gmcapsule/gemini.py b/gmcapsule/gemini.py[m [1mindex 1a48fb4..697a81e 100644[m [1m--- a/gmcapsule/gemini.py[m [1m+++ b/gmcapsule/gemini.py[m [36m@@ -81,7 +81,6 @@[m [mclass Worker(threading.Thread):[m self.jobs = server.work_queue[m [m def run(self):[m [31m- #print(f'Worker {self.id} started')[m while True:[m job = self.jobs.get()[m if job is None:[m [36m@@ -90,10 +89,17 @@[m [mclass Worker(threading.Thread):[m try:[m self.process_request(stream, from_addr)[m except Exception as error:[m [31m- report_error(stream, 42, str(error))[m [32m+[m[32m import traceback[m [32m+[m[32m traceback.print_exc()[m [32m+[m[32m try:[m [32m+[m[32m report_error(stream, 42, str(error))[m [32m+[m[32m except:[m [32m+[m[32m pass[m finally:[m [31m- stream.shutdown()[m [31m- #print(f'Worker {self.id} stopped')[m [32m+[m[32m try:[m [32m+[m[32m stream.shutdown()[m [32m+[m[32m except:[m [32m+[m[32m pass[m [m def log(self, *args):[m print(time.strftime('%Y-%m-%d %H:%M:%S'), f'[{self.id}]', '--', *args)[m [1mdiff --git a/gmcapsule/modules/99_static.py b/gmcapsule/modules/99_static.py[m [1mindex d0d4827..5fbd9b4 100644[m [1m--- a/gmcapsule/modules/99_static.py[m [1m+++ b/gmcapsule/modules/99_static.py[m [36m@@ -12,10 +12,10 @@[m [mMETA = '.meta'[m [m def check_meta_rules(path, hostname):[m cfg = Capsule.config()[m [31m- root = (cfg.root_dir() / hostname).resolve()[m [31m- dir = path.parent[m [32m+[m[32m root = cfg.root_dir() / hostname[m [32m+[m[32m dir = Path(path).parent[m while True:[m [31m- if not str(dir.resolve()).startswith(str(root)):[m [32m+[m[32m if not str(dir).startswith(str(root)):[m break[m if (dir / META).exists():[m for rule in open(dir / META, 'rt').readlines():[m [36m@@ -46,21 +46,21 @@[m [mdef serve_file(req):[m if seg != '.' and seg != '..' and seg.startswith('.'):[m return 51, "Not found"[m [m [31m- host_root = (cfg.root_dir() / req.hostname).resolve()[m [31m- path = (host_root / req.path[1:]).resolve()[m [31m- if not str(path).startswith(str(host_root)):[m [32m+[m[32m host_root = cfg.root_dir() / req.hostname[m [32m+[m[32m path = os.path.normpath(host_root / req.path[1:])[m [32m+[m[32m if not path.startswith(str(host_root)):[m return 51, "Not found"[m [m [31m- if os.path.isdir(str(path)):[m [32m+[m[32m if os.path.isdir(path):[m if not req.path.endswith('/'):[m return 31, req.path + '/'[m [31m- path = path / 'index.gmi'[m [32m+[m[32m path = str(Path(path) / 'index.gmi')[m [m status, meta = check_meta_rules(path, req.hostname)[m if status and status != 20:[m return status, meta[m [m [31m- if not os.path.exists(str(path)):[m [32m+[m[32m if not os.path.exists(path):[m return 51, "Not found"[m [m return status, meta, (open(path, 'rb').read() if status == 20 else None)[m
text/gemini; charset=utf-8
This content has been proxied by September (ba2dc).