Partial fix for https://github.com/go-gitea/gitea/issues/17642. Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>