Add test for "fetch redirect", add CSS value validation for external render (#37207)

By the way, fix the checkAppUrl message for #37212
This commit is contained in:
wxiaoguang
2026-04-14 21:11:08 +08:00
committed by GitHub
parent 9327b1808e
commit 699eb41e7c
7 changed files with 105 additions and 5 deletions
+3 -2
View File
@@ -18,9 +18,10 @@ func FetchRedirectDelegate(resp http.ResponseWriter, req *http.Request) {
// then frontend needs this delegate to redirect to the new location with hash correctly.
redirect := req.FormValue("redirect")
if req.Method != http.MethodPost || !httplib.IsCurrentGiteaSiteURL(req.Context(), redirect) {
resp.WriteHeader(http.StatusBadRequest)
http.Error(resp, "Bad Request", http.StatusBadRequest)
return
}
resp.Header().Add("Location", redirect)
// no OpenRedirect, the "redirect" is validated by "IsCurrentGiteaSiteURL" above
resp.Header().Set("Location", redirect)
resp.WriteHeader(http.StatusSeeOther)
}