This commit is contained in:
2026-04-08 18:14:11 +09:00
parent c4968a6b78
commit 8caa642dda
7 changed files with 41 additions and 16 deletions
+4 -4
View File
@@ -99,7 +99,7 @@ async def default_response(request: Request, full_path: str) -> Response:
if static := resolve_static_file(full_path):
return FileResponse(static)
except PermissionError:
return error_page(templates, request, 403, "ディレクトリトラバーサルね、知ってる。公開してないところ覗きたいの?えっt")
return error_page(templates, request, 403, "何をしてるんです?脆弱性報告のためならいいのですが、データ盗んで悪用するためなら今すぐにやめてくださいね?", "ディレクトリトラバーサルね、知ってる。公開してないところ覗きたいの?えっt")
if full_path in ["", "/"]:
template_candidates = ["index.html"]
@@ -127,12 +127,12 @@ async def default_response(request: Request, full_path: str) -> Response:
try:
path = Path.cwd().joinpath("public", "shorturls.json")
if not path.exists():
return error_page(templates, request, 500, "設定ファイルぐらい用意しておけよ!")
return error_page(templates, request, 500, "短縮URLの処理のためのJSONファイルがありません。", "設定ファイルぐらい用意しておけよ!")
shorturls = json.load(path.open("r", encoding="utf-8"))
except Exception:
return error_page(templates, request, 500, "なにこの設定ファイル読めないじゃない!")
return error_page(templates, request, 500, "短縮URLの処理のためのJSONファイルを正常に読み込めませんでした。", "なにこの設定ファイル読めないじゃない!")
if result := resolve_shorturl(shorturls, full_path):
return RedirectResponse(url=result)
return error_page(templates, request, 404, "そんなページ知らないっ!")
return error_page(templates, request, 404, "リクエストしたページは現在ご利用になれません。削除/移動されたか、URLが間違っている可能性があります。", "そんなページ知らないっ!")