mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
fix: Fix package info for 404 errors
We try to find packages when a user enters a URL like /somepkg or accidentally opens /somepkg.git in the browser. However, it currently also does this for URL's like /pkgbase/doesnotexist and falsely interprets "pkgbase" part as a package or pkgbase name. This in combination with a pkgbase that is named "pkgbase" generates some misleading 404 message for URL's like /pkgbase/doesnotexist. That being said, we should probably add pkgbase to the blacklist check as well (we do this for pkgname already) and add things like "pkgbase" to the blacklist -> Will be picked up in another commit. Signed-off-by: moson <moson@archlinux.org>
This commit is contained in:
parent
319c565cb9
commit
057685f304
2 changed files with 16 additions and 2 deletions
|
@ -212,7 +212,7 @@ async def http_exception_handler(request: Request, exc: HTTPException) -> Respon
|
|||
if exc.status_code == http.HTTPStatus.NOT_FOUND:
|
||||
tokens = request.url.path.split("/")
|
||||
matches = re.match("^([a-z0-9][a-z0-9.+_-]*?)(\\.git)?$", tokens[1])
|
||||
if matches:
|
||||
if matches and len(tokens) == 2:
|
||||
try:
|
||||
pkgbase = get_pkg_or_base(matches.group(1))
|
||||
context = pkgbaseutil.make_context(request, pkgbase)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue