summaryrefslogtreecommitdiffstats
path: root/services
diff options
context:
space:
mode:
authorSybren <122987084+drsybren@users.noreply.github.com>2023-01-19 19:24:40 +0100
committerGitHub <noreply@github.com>2023-01-19 13:24:40 -0500
commitb383652e02294796fdab7270e2cdb5a0d7413511 (patch)
treeb7081b9c22ccd81baffbb0f7690fcdc445b58b36 /services
parent9f919cf08339e8ec8f6b0b2a0dcafb3ea905fbec (diff)
downloadgitea-b383652e02294796fdab7270e2cdb5a0d7413511.tar.gz
gitea-b383652e02294796fdab7270e2cdb5a0d7413511.zip
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.
Diffstat (limited to 'services')
-rw-r--r--services/migrations/gitea_uploader.go4
1 files changed, 3 insertions, 1 deletions
diff --git a/services/migrations/gitea_uploader.go b/services/migrations/gitea_uploader.go
index f43c7378b8..20370d99f9 100644
--- a/services/migrations/gitea_uploader.go
+++ b/services/migrations/gitea_uploader.go
@@ -468,7 +468,9 @@ func (g *GiteaLocalUploader) CreateComments(comments ...*base.Comment) error {
switch cm.Type {
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 {
cm.RemovedAssignee = true
}