diff --git a/50_bubble.py b/50_bubble.py index 8ebede2..861e45f 100644 --- a/50_bubble.py +++ b/50_bubble.py @@ -18,7 +18,7 @@ from utils import * from worker import *   -__version__ = '8.7' +__version__ = '8.8'   class Bubble: @@ -952,10 +952,13 @@ Deleting a subspace will delete all posts and comments in the subspace, i.e., th elif req.path.startswith(self.path + 'u/') or \ req.path.startswith(self.path + 's/') or \ req.path.startswith(self.path + 'tag'): - page = make_post_page_or_configure_feed(session) - if page: - return page - # NOTE: Fall through to feed generation below. + try: + page = make_post_page_or_configure_feed(session) + if page: + return page + # NOTE: Fall through to feed generation below. + except ValueError: + raise GeminiError(42, "Invalid value")  elif req.path == self.path + 'all': session.feed_mode = 'all' diff --git a/feeds.py b/feeds.py index acee678..719ef88 100644 --- a/feeds.py +++ b/feeds.py @@ -15,7 +15,7 @@ def make_post_page_or_configure_feed(session): db = session.db req = session.req path = req.path[len(session.path):] - found = re.match(r'(u|s)/([\w%-]+)(/(post|compose|image|file|issues|admin|tag|index))?(/([\w\d-]+)(.*))?', path) + found = re.fullmatch(r'(u|s)/([\w%-]+)(/(post|compose|image|file|issues|admin|tag|index))?(/([\w\d-]+)(.*))?(/)?', path) if not found and not path.startswith('tag'): return 59, 'Bad request'  @@ -26,6 +26,9 @@ def make_post_page_or_configure_feed(session): action = found.group(4) arg = found.group(6) arg2 = found.group(7) + if found.group(8) == '/': + # Redirect to the correct URL. + raise GeminiError(30, session.path + path[:-1] + ("?" + req.query if req.query != None else "")) else: # Tag filtering All Posts. found = re.match(r'(tag)(/([\w\d-]+)(.*))?', path)