diff options
author | Sybren <122987084+drsybren@users.noreply.github.com> | 2023-01-19 19:24:40 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-19 13:24:40 -0500 |
commit | b383652e02294796fdab7270e2cdb5a0d7413511 (patch) | |
tree | b7081b9c22ccd81baffbb0f7690fcdc445b58b36 /services | |
parent | 9f919cf08339e8ec8f6b0b2a0dcafb3ea905fbec (diff) | |
download | gitea-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.go | 4 |
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 } |