From 330daaab5b3653767d2c7c82de4f385b4bb71df6 Mon Sep 17 00:00:00 2001
From: Andreas Shimokawa Create a repo named 'pages' in your user account or org, push static content, HTML, style, fonts, images. Share your rendered content via: Codeberg Pages. Static Pages for your Projects.
https://" . $_SERVER["HTTP_HOST"] . "/<username>/
Share your rendered content via:
https://<username>." . $_SERVER["HTTP_HOST"] . "
Welcome to Codeberg.org!
@@ -30,14 +30,21 @@ if ($request_url === "/") { } # Restrict allowed characters in request URI: -if (preg_match("/^\/[a-zA-Z0-9_ +\-\/\.]+\$/", $request_url) != 1) { +if (preg_match("/^\/[a-zA-Z0-9_ +\-\/\.]*\$/", $request_url) != 1) { send_response(404, "invalid request URL"); } $git_prefix = "/data/git/gitea-repositories"; $parts = explode("/", $request_url); $parts = array_diff($parts, array("")); # Remove empty parts in URL -$owner = strtolower(array_shift($parts)); + +$parts_dot = explode(".",$_SERVER["HTTP_HOST"]); +if (count($parts_dot) != 3) +{ + send_response(404, "invalid subdomain"); +} +$owner = $parts_dot[0]; + $git_root = realpath("$git_prefix/$owner/pages.git"); $file_url = implode("/", $parts);