Merge pull request #944 from amiaogo/fix/opera-log-utf8-truncate

fix🐛: truncate opera log jsonResult by rune to keep valid UTF-8
This commit is contained in:
wenjianzhang
2026-09-26 14:32:22 +08:00
committed by GitHub
+3 -2
View File
@@ -75,9 +75,10 @@ func SaveOperaLog(message storage.Messager) (err error) {
return nil
}
// 超出100个字符返回值截断
if len(l.JsonResult) > 100 {
l.JsonResult = l.JsonResult[:100]
if r := []rune(l.JsonResult); len(r) > 100 {
l.JsonResult = string(r[:100])
}
err = db.Create(&l).Error
if err != nil {
log.Errorf("db create error, %s", err.Error())