chore: tidy up uploading migration code (#12577)

- Validate and sanitize topics.
- Cap topics at 25 (limit used elsewhere, now unified constant).
- Add more details and rephrase common user-facing error messages.

Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/12577
This commit is contained in:
Gusted 2026-05-16 11:46:14 +02:00 committed by Gusted
commit aae19e6c19
5 changed files with 123 additions and 100 deletions

View file

@ -20,6 +20,9 @@ func init() {
db.RegisterModel(new(RepoTopic))
}
// MaxTopicsPerRepo caps the amount of topics allowed per repository.
const MaxTopicsPerRepo = 25
var topicPattern = regexp.MustCompile(`^[a-z0-9][-.a-z0-9]*$`)
// Topic represents a topic of repositories