From a16b1f43cac2381ff4acc5c62878a29bb7e6ed55 Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Wed, 7 Dec 2011 14:39:40 -0800 Subject: [PATCH] jsonsign: make sure armored public key ends in a newline Change-Id: Ia0e52c6e011db295c21eb8b1b6b6534873bf6310 --- lib/go/camli/jsonsign/keys.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/go/camli/jsonsign/keys.go b/lib/go/camli/jsonsign/keys.go index 15fbe971a..aab926a89 100644 --- a/lib/go/camli/jsonsign/keys.go +++ b/lib/go/camli/jsonsign/keys.go @@ -113,6 +113,8 @@ func EntityFromSecring(keyId, keyFile string) (*openpgp.Entity, os.Error) { return entity, nil } +var newlineBytes = []byte("\n") + func ArmoredPublicKey(entity *openpgp.Entity) (string, os.Error) { var buf bytes.Buffer wc, err := armor.Encode(&buf, openpgp.PublicKeyType, nil) @@ -124,5 +126,8 @@ func ArmoredPublicKey(entity *openpgp.Entity) (string, os.Error) { return "", err } wc.Close() + if !bytes.HasSuffix(buf.Bytes(), newlineBytes) { + buf.WriteString("\n") + } return buf.String(), nil }