You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
728 B

  1. // Copyright 2017 The Gitea Authors. All rights reserved.
  2. // Use of this source code is governed by a MIT-style
  3. // license that can be found in the LICENSE file.
  4. package migrations
  5. import (
  6. "html"
  7. "code.gitea.io/gitea/models"
  8. "github.com/go-xorm/xorm"
  9. )
  10. func unescapeUserFullNames(x *xorm.Engine) (err error) {
  11. const batchSize = 100
  12. for start := 0; ; start += batchSize {
  13. users := make([]*models.User, 0, batchSize)
  14. if err := x.Limit(start, batchSize).Find(users); err != nil {
  15. return err
  16. }
  17. if len(users) == 0 {
  18. return nil
  19. }
  20. for _, user := range users {
  21. user.FullName = html.UnescapeString(user.FullName)
  22. if _, err := x.Cols("full_name").Update(user); err != nil {
  23. return err
  24. }
  25. }
  26. }
  27. }