Stricter slug path processing, only serve site on 404 of missing article paths, not any other path.
This commit is contained in:
+3
-2
@@ -563,8 +563,9 @@ async def show_page(request: Request, path: str) -> HTMLResponse | Response:
|
|||||||
"""
|
"""
|
||||||
path = path.strip("/")
|
path = path.strip("/")
|
||||||
if path and _is_reserved(path):
|
if path and _is_reserved(path):
|
||||||
# Reserved slug shape: never content — no tree lookup.
|
# Invalid slug shape: not a content URL, let FastAPI return its
|
||||||
return HTMLResponse(views.render_not_found(data.menu, path, data.brand, data.custom_css, data.theme), 404)
|
# built-in 404 instead of rendering an editable article page.
|
||||||
|
raise HTTPException(404)
|
||||||
chain = resolve(data.menu, path)
|
chain = resolve(data.menu, path)
|
||||||
node = chain[-1] if chain else None
|
node = chain[-1] if chain else None
|
||||||
if node is not None and node.published and node.content is not None:
|
if node is not None and node.published and node.content is not None:
|
||||||
|
|||||||
+1
-1
@@ -353,7 +353,7 @@ def render_not_found(
|
|||||||
doc = E.article
|
doc = E.article
|
||||||
with doc:
|
with doc:
|
||||||
doc.h1("Not Found")
|
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)
|
scripts, styles = _page_assets(theme)
|
||||||
return str(
|
return str(
|
||||||
_layout(styles, scripts, custom_css, theme)(
|
_layout(styles, scripts, custom_css, theme)(
|
||||||
|
|||||||
Reference in New Issue
Block a user