mirror of
1
Fork 0

Convert git commit summary to valid UTF8. (#28356) (#28358)

Backport #28356 by @darrinsmart

The summary string ends up in the database, and (at least) MySQL &
PostgreSQL require valid UTF8 strings.

Fixes #28178

Co-authored-by: darrinsmart <darrin@djs.to>
Co-authored-by: Darrin Smart <darrin@filmlight.ltd.uk>
(cherry picked from commit fef34790bb)
This commit is contained in:
Giteabot 2023-12-05 17:19:08 +08:00 committed by Earl Warren
parent 693c2b4f15
commit 346635605d
No known key found for this signature in database
GPG Key ID: 0579CB2928A78A00
1 changed files with 2 additions and 1 deletions

View File

@ -43,8 +43,9 @@ func (c *Commit) Message() string {
}
// Summary returns first line of commit message.
// The string is forced to be valid UTF8
func (c *Commit) Summary() string {
return strings.Split(strings.TrimSpace(c.CommitMessage), "\n")[0]
return strings.ToValidUTF8(strings.Split(strings.TrimSpace(c.CommitMessage), "\n")[0], "?")
}
// ParentID returns oid of n-th parent (0-based index).