aboutsummaryrefslogtreecommitdiffstats
path: root/plumbing
diff options
context:
space:
mode:
authorChris Marchesi <chrism@vancluevertech.com>2018-08-21 22:20:09 -0700
committerChris Marchesi <chrism@vancluevertech.com>2018-08-21 22:20:09 -0700
commit8c3c8b30b3394677d8eb16b159bfe9b4f61726a8 (patch)
treeed0068ded669ea4c7e65fd34ebd5d2d39070a6d8 /plumbing
parent9b73a3ead6559576cb017b09c41c23c251b5af1c (diff)
downloadgo-git-8c3c8b30b3394677d8eb16b159bfe9b4f61726a8.tar.gz
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 <chrism@vancluevertech.com>
Diffstat (limited to 'plumbing')
-rw-r--r--plumbing/object/tag.go7
1 files changed, 6 insertions, 1 deletions
diff --git a/plumbing/object/tag.go b/plumbing/object/tag.go
index 6354973..03749f9 100644
--- a/plumbing/object/tag.go
+++ b/plumbing/object/tag.go
@@ -195,8 +195,13 @@ func (t *Tag) encode(o plumbing.EncodedObject, includeSig bool) (err error) {
return err
}
+ // Note that this is highly sensitive to what it sent along in the message.
+ // Message *always* needs to end with a newline, or else the message and the
+ // signature will be concatenated into a corrupt object. Since this is a
+ // lower-level method, we assume you know what you are doing and have already
+ // done the needful on the message in the caller.
if includeSig {
- if _, err = fmt.Fprint(w, "\n"+t.PGPSignature); err != nil {
+ if _, err = fmt.Fprint(w, t.PGPSignature); err != nil {
return err
}
}