Stricter slug path processing, only serve site on 404 of missing article paths, not any other path.

This commit is contained in:
2026-08-17 22:02:48 +00:00
parent a4fab3dcc9
commit 9fcf4ee8e0
2 changed files with 4 additions and 3 deletions
+3 -2
View File
@@ -563,8 +563,9 @@ async def show_page(request: Request, path: str) -> HTMLResponse | Response:
"""
path = path.strip("/")
if path and _is_reserved(path):
# Reserved slug shape: never content — no tree lookup.
return HTMLResponse(views.render_not_found(data.menu, path, data.brand, data.custom_css, data.theme), 404)
# Invalid slug shape: not a content URL, let FastAPI return its
# built-in 404 instead of rendering an editable article page.
raise HTTPException(404)
chain = resolve(data.menu, path)
node = chain[-1] if chain else None
if node is not None and node.published and node.content is not None:
+1 -1
View File
@@ -353,7 +353,7 @@ def render_not_found(
doc = E.article
with doc:
doc.h1("Not Found")
doc.p(f"No page at /{path}.")
doc.p(f"No article at /{path}. If there was before, it may have been deleted.")
scripts, styles = _page_assets(theme)
return str(
_layout(styles, scripts, custom_css, theme)(