File tree Expand file tree Collapse file tree 1 file changed +7
-1
lines changed
Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ import (
1313 "regexp"
1414 "strings"
1515 "time"
16+ "unicode/utf8"
1617
1718 "code.gitea.io/gitea/models/db"
1819 git_model "code.gitea.io/gitea/models/git"
@@ -861,7 +862,12 @@ func GetSquashMergeCommitMessages(ctx context.Context, pr *issues_model.PullRequ
861862
862863 _ , _ = fmt .Fprintf (& stringBuilder , "* %s\n \n " , msg )
863864 if maxMsgSize > 0 && stringBuilder .Len () >= maxMsgSize {
864- tmp := strings .ToValidUTF8 (stringBuilder .String ()[:maxMsgSize ]+ "..." , "?" )
865+ tmp := stringBuilder .String ()
866+ wasValidUtf8 := utf8 .ValidString (tmp )
867+ tmp = tmp [:maxMsgSize ] + "..."
868+ if wasValidUtf8 {
869+ tmp = strings .ToValidUTF8 (tmp , "?" )
870+ }
865871 stringBuilder .Reset ()
866872 stringBuilder .WriteString (tmp )
867873 break
You can’t perform that action at this time.
0 commit comments