Skip to content

Commit d0d82d6

Browse files
darrinsmartDarrin Smart
authored andcommitted
Convert git commit summary to valid UTF8. (go-gitea#28356)
The summary string ends up in the database, and (at least) MySQL & PostgreSQL require valid UTF8 strings. Fixes go-gitea#28178 Co-authored-by: Darrin Smart <[email protected]>
1 parent 1b8d6cb commit d0d82d6

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

modules/git/commit.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,9 @@ func (c *Commit) Message() string {
4343
}
4444

4545
// Summary returns first line of commit message.
46+
// The string is forced to be valid UTF8
4647
func (c *Commit) Summary() string {
47-
return strings.Split(strings.TrimSpace(c.CommitMessage), "\n")[0]
48+
return strings.ToValidUTF8(strings.Split(strings.TrimSpace(c.CommitMessage), "\n")[0], "?")
4849
}
4950

5051
// ParentID returns oid of n-th parent (0-based index).

0 commit comments

Comments
 (0)