diff options
Diffstat (limited to 'cmd/gitaly-git2go')
-rw-r--r-- | cmd/gitaly-git2go/merge.go | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/cmd/gitaly-git2go/merge.go b/cmd/gitaly-git2go/merge.go index 1e5c13aa4..7eb6c691a 100644 --- a/cmd/gitaly-git2go/merge.go +++ b/cmd/gitaly-git2go/merge.go @@ -6,6 +6,7 @@ import ( "errors" "flag" "fmt" + "strings" "time" git "github.com/libgit2/git2go/v30" @@ -74,12 +75,23 @@ func lookupCommit(repo *git.Repository, ref string) (*git.Commit, error) { return commit, nil } +func sanitizeSignatureInfo(info string) string { + return strings.Map(func(r rune) rune { + switch r { + case '<', '>', '\n': + return -1 + default: + return r + } + }, info) +} + func (cmd *mergeSubcommand) Run() error { if err := cmd.verifyOptions(); err != nil { return fmt.Errorf("invalid options: %w", err) } - var date time.Time + var date time.Time = time.Now() if cmd.authorDate != "" { var err error date, err = time.Parse("Mon Jan 2 15:04:05 2006 -0700", cmd.authorDate) @@ -118,8 +130,8 @@ func (cmd *mergeSubcommand) Run() error { } committer := git.Signature{ - Name: cmd.authorName, - Email: cmd.authorMail, + Name: sanitizeSignatureInfo(cmd.authorName), + Email: sanitizeSignatureInfo(cmd.authorMail), When: date, } |