From 0e72967698566d668222f5a3fa48b6ea01da1fb1 Mon Sep 17 00:00:00 2001 From: Gwendolyn Date: Sat, 6 Jan 2024 18:58:13 +0100 Subject: [PATCH] optional theme in tile server URLs theme is not optional in core because it has optional access restrictions already, but in an actual deployment all tiles are loaded through the tile server, and this is only for backwards compatibility with external services --- src/c3nav/tileserver/wsgi.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/c3nav/tileserver/wsgi.py b/src/c3nav/tileserver/wsgi.py index 993d570f..38c82789 100644 --- a/src/c3nav/tileserver/wsgi.py +++ b/src/c3nav/tileserver/wsgi.py @@ -32,7 +32,7 @@ if os.environ.get('C3NAV_LOGFILE'): class TileServer: def __init__(self): - self.path_regex = re.compile(r'^/(\d+)/(-?\d+)/(-?\d+)/(-?\d+)/(-?\d+).png$') + self.path_regex = re.compile(r'^/(\d+)/(-?\d+)/(-?\d+)/(-?\d+)(/(-?\d+))?.png$') self.cookie_regex = re.compile(r'(^| )c3nav_tile_access="?([^;" ]+)"?') @@ -239,7 +239,9 @@ class TileServer: if match is None: return self.not_found(start_response, b'invalid tile path.') - level, zoom, x, y, theme = match.groups() + level, zoom, x, y, _, theme = match.groups() + if theme is None: + theme = 0 zoom = int(zoom) if not (-2 <= zoom <= 5):