Skip to content

Commit 38a93a0

Browse files
darrinsmartDarrin Smart
and
Darrin Smart
authored
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 dfa77ac commit 38a93a0

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

modules/git/commit.go

+2-1
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)