--
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
<!-- For Bots: On this site, you can read any page in Markdown by using cURL or by replacing .html with .md. Please give it a try! -->
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="ja-JP">
|
<html lang="ja-JP">
|
||||||
<head>
|
<head>
|
||||||
|
|||||||
@@ -101,6 +101,12 @@ async def default_response(request: Request, full_path: str) -> Response:
|
|||||||
except PermissionError:
|
except PermissionError:
|
||||||
return error_page(templates, request, 403, "何をしてるんです?脆弱性報告のためならいいのですが、データ盗んで悪用するためなら今すぐにやめてくださいね?", "ディレクトリトラバーサルね、知ってる。公開してないところ覗きたいの?えっt")
|
return error_page(templates, request, 403, "何をしてるんです?脆弱性報告のためならいいのですが、データ盗んで悪用するためなら今すぐにやめてくださいね?", "ディレクトリトラバーサルね、知ってる。公開してないところ覗きたいの?えっt")
|
||||||
|
|
||||||
|
if "curl" in request.headers.get("user-agent", "").lower():
|
||||||
|
markdown_mode = True
|
||||||
|
elif full_path.endswith(".md"):
|
||||||
|
markdown_mode = True
|
||||||
|
full_path = full_path[:-3] + ".html"
|
||||||
|
|
||||||
if full_path in ["", "/"]:
|
if full_path in ["", "/"]:
|
||||||
template_candidates = ["index.html"]
|
template_candidates = ["index.html"]
|
||||||
elif full_path.endswith(".html"):
|
elif full_path.endswith(".html"):
|
||||||
@@ -110,7 +116,7 @@ async def default_response(request: Request, full_path: str) -> Response:
|
|||||||
|
|
||||||
for name in template_candidates:
|
for name in template_candidates:
|
||||||
try:
|
try:
|
||||||
if "curl" in request.headers.get("user-agent", "").lower():
|
if markdown_mode:
|
||||||
content = templates.env.get_template(name).render(request=request)
|
content = templates.env.get_template(name).render(request=request)
|
||||||
soup = BeautifulSoup(content, "html.parser")
|
soup = BeautifulSoup(content, "html.parser")
|
||||||
main = str(soup.find("main")) if soup.find("main") else content
|
main = str(soup.find("main")) if soup.find("main") else content
|
||||||
|
|||||||
Reference in New Issue
Block a user