Skip to content
This repository was archived by the owner on Sep 11, 2020. It is now read-only.

Commit 8c3c8b3

Browse files
committed
plumbing: object, don't add extra newline on PGP signature
Tag encoding/decoding seems to be a lot more sensitive to requiring the exact expected format in the object, which generally includes messages canonicalized so that they have a newline on the end (even if they didn't before). As such, the message should be written with the newline (no need for an extra), and the PGP signature right after that, which will be newline split already, so there's no need to split it again. All of this means it's very important for the caller to send the message in the correct format - which I'm correcting in the next commit. Signed-off-by: Chris Marchesi <[email protected]>
1 parent 9b73a3e commit 8c3c8b3

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

plumbing/object/tag.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,8 +195,13 @@ func (t *Tag) encode(o plumbing.EncodedObject, includeSig bool) (err error) {
195195
return err
196196
}
197197

198+
// Note that this is highly sensitive to what it sent along in the message.
199+
// Message *always* needs to end with a newline, or else the message and the
200+
// signature will be concatenated into a corrupt object. Since this is a
201+
// lower-level method, we assume you know what you are doing and have already
202+
// done the needful on the message in the caller.
198203
if includeSig {
199-
if _, err = fmt.Fprint(w, "\n"+t.PGPSignature); err != nil {
204+
if _, err = fmt.Fprint(w, t.PGPSignature); err != nil {
200205
return err
201206
}
202207
}

0 commit comments

Comments
 (0)