Fix assignment to `cm.AssigneeID` when importing comments (#22528)

This is a fix for https://github.com/go-gitea/gitea/pull/22510

The code assumed that the `AssigneeID` from the comment YAML was an
`int64`, but it is actually an `int`, causing a panic. It also had no
check on whether the type cast was actually valid, so badly formatted
YAML could also cause a panic.

Both these issues have been fixed.
pull/22535/head^2
Sybren 2 years ago committed by GitHub
parent 9f919cf083
commit b383652e02
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      services/migrations/gitea_uploader.go

@ -468,7 +468,9 @@ func (g *GiteaLocalUploader) CreateComments(comments ...*base.Comment) error {
switch cm.Type { switch cm.Type {
case issues_model.CommentTypeAssignees: case issues_model.CommentTypeAssignees:
cm.AssigneeID = comment.Meta["AssigneeID"].(int64) if assigneeID, ok := comment.Meta["AssigneeID"].(int); ok {
cm.AssigneeID = int64(assigneeID)
}
if comment.Meta["RemovedAssigneeID"] != nil { if comment.Meta["RemovedAssigneeID"] != nil {
cm.RemovedAssignee = true cm.RemovedAssignee = true
} }

Loading…
Cancel
Save