mirror of
				https://github.com/go-gitea/gitea.git
				synced 2025-10-31 21:28:11 +09:00 
			
		
		
		
	Handle empty author names (#21902)
Although git does expect that author names should be of the form: `NAME <EMAIL>` some users have been able to create commits with: `<EMAIL>` Fix #21900 Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: delvh <dev.lh@web.de> Co-authored-by: Lauris BH <lauris@nix.lv> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
This commit is contained in:
		| @@ -11,6 +11,7 @@ import ( | ||||
| 	"bytes" | ||||
| 	"fmt" | ||||
| 	"strconv" | ||||
| 	"strings" | ||||
| 	"time" | ||||
| ) | ||||
|  | ||||
| @@ -51,7 +52,9 @@ func newSignatureFromCommitline(line []byte) (sig *Signature, err error) { | ||||
| 		return | ||||
| 	} | ||||
|  | ||||
| 	sig.Name = string(line[:emailStart-1]) | ||||
| 	if emailStart > 0 { // Empty name has already occurred, even if it shouldn't | ||||
| 		sig.Name = strings.TrimSpace(string(line[:emailStart-1])) | ||||
| 	} | ||||
| 	sig.Email = string(line[emailStart+1 : emailEnd]) | ||||
|  | ||||
| 	hasTime := emailEnd+2 < len(line) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user