encoding/pem: can't decode encoded message (original) (raw)

encoding/pem successfully decodes a message in the following program; but if the message is re-encoded, decoding fails:

package main

import "encoding/pem"

func main() { data := []byte("-----BEGIN foo-----\n\n-----END foo-----") b, _ := pem.Decode(data) if b == nil { return } enc := pem.EncodeToMemory(b) b1, _ := pem.Decode(enc) if b1 == nil { panic("can't decode encoded") } }

Either the first Decode should fail, or the second Decode should succeed.

on commit 6551803