From 0c6c986ddd9855c8fd5f28771f824d7da73d4dc3 Mon Sep 17 00:00:00 2001 From: Máximo Cuadros Date: Mon, 9 Jan 2017 09:50:29 +0100 Subject: plumbing: fix signature with `>` before `<` parsing (#204) --- plumbing/object/object.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'plumbing/object/object.go') diff --git a/plumbing/object/object.go b/plumbing/object/object.go index 8bdbb2a..faf7e7f 100644 --- a/plumbing/object/object.go +++ b/plumbing/object/object.go @@ -83,12 +83,16 @@ type Signature struct { // Decode decodes a byte slice into a signature func (s *Signature) Decode(b []byte) { - open := bytes.IndexByte(b, '<') - close := bytes.IndexByte(b, '>') + open := bytes.LastIndexByte(b, '<') + close := bytes.LastIndexByte(b, '>') if open == -1 || close == -1 { return } + if close < open { + return + } + s.Name = string(bytes.Trim(b[:open], " ")) s.Email = string(b[open+1 : close]) -- cgit