aboutsummaryrefslogtreecommitdiff
path: root/file/file.go
diff options
context:
space:
mode:
Diffstat (limited to 'file/file.go')
-rw-r--r--file/file.go9
1 files changed, 5 insertions, 4 deletions
diff --git a/file/file.go b/file/file.go
index 5b3fbcf..c6fb266 100644
--- a/file/file.go
+++ b/file/file.go
@@ -18,7 +18,7 @@ const (
ModeSec os.FileMode = 0600
ModePub os.FileMode = 0644
ModeSig os.FileMode = 0644
- untrusted = "untrusted comment:"
+ untrusted = "untrusted comment: "
)
// Original Error: "invalid comment in %s; must start with 'untrusted comment: '"
@@ -53,7 +53,8 @@ func Decode(r io.Reader, u encoding.BinaryUnmarshaler) (string, []byte, error) {
if !strings.HasPrefix(comment, untrusted) {
return "", nil, ErrComment
}
- comment = strings.TrimSpace(comment[len(untrusted):])
+ comment = strings.TrimPrefix(comment, untrusted)
+ comment = strings.TrimSpace(comment)
raw, err := buf.ReadString('\n')
if err != nil {
@@ -89,8 +90,8 @@ func Encode(w io.Writer, u encoding.BinaryMarshaler, comment string, msg []byte)
if err != nil {
return err
}
- fmt.Fprintln(w, untrusted, comment)
- fmt.Fprintln(w, base64.StdEncoding.EncodeToString(raw))
+ fmt.Fprintf(w, "%s%s\n", untrusted, comment)
+ fmt.Fprintf(w, "%s\n", base64.StdEncoding.EncodeToString(raw))
w.Write(msg)
return nil
}