aboutsummaryrefslogtreecommitdiff
path: root/src/encoding/pem
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2017-03-31 16:15:51 -0400
committerRuss Cox <rsc@golang.org>2017-04-03 13:56:30 +0000
commit65c17a05e98866d1e29a5d53fc21b0221760698d (patch)
tree4a48cd11fe4ae99ca3a5e7ca478b68249522e82a /src/encoding/pem
parent64f00fb150fff62a144e188e00f59f044ffb7d23 (diff)
downloadgo-65c17a05e98866d1e29a5d53fc21b0221760698d.tar.gz
go-65c17a05e98866d1e29a5d53fc21b0221760698d.zip
encoding/pem: do not try to round trip value with leading/trailing space
The header is literally Key: Value If the value or the key has leading or trailing spaces, those will be lost by the round trip. Found because testing/quick returns different values now. Change-Id: I0f574bdbb5990689509c24309854d8f814b5efa0 Reviewed-on: https://go-review.googlesource.com/39211 Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Diffstat (limited to 'src/encoding/pem')
-rw-r--r--src/encoding/pem/pem_test.go7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/encoding/pem/pem_test.go b/src/encoding/pem/pem_test.go
index 6a85a60431..7ab0e8f61d 100644
--- a/src/encoding/pem/pem_test.go
+++ b/src/encoding/pem/pem_test.go
@@ -207,9 +207,10 @@ func TestLineBreaker(t *testing.T) {
func TestFuzz(t *testing.T) {
testRoundtrip := func(block Block) bool {
- for key := range block.Headers {
- if strings.Contains(key, ":") {
- // Keys with colons cannot be encoded.
+ for key, val := range block.Headers {
+ if strings.ContainsAny(key, ":\r\n") || strings.ContainsAny(val, "\r\n") || strings.TrimSpace(key) != key || strings.TrimSpace(val) != val {
+ // Keys with colons or newlines cannot be encoded.
+ // Keys/values with surrounding spaces might lose theirs.
return true
}
}