Fix #30921 (cherry picked from commit 821d2fc2a3cc897f21d707455850177077b72410) (cherry picked from commit 50b4e7f26e) Equivalent to the Gitea v1.22 commit (cherry picked from commit 8eac16de217978c1f7034f8e360f54d8d638e95e)
50b4e7f26e