mirror of
				https://gitee.com/gitea/gitea
				synced 2025-11-04 16:40:24 +08:00 
			
		
		
		
	Convert git commit summary to valid UTF8. (#28356)
The summary string ends up in the database, and (at least) MySQL & PostgreSQL require valid UTF8 strings. Fixes #28178 Co-authored-by: Darrin Smart <darrin@filmlight.ltd.uk>
This commit is contained in:
		@@ -43,8 +43,9 @@ func (c *Commit) Message() string {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Summary returns first line of commit message.
 | 
					// Summary returns first line of commit message.
 | 
				
			||||||
 | 
					// The string is forced to be valid UTF8
 | 
				
			||||||
func (c *Commit) Summary() string {
 | 
					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).
 | 
					// ParentID returns oid of n-th parent (0-based index).
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user