Commit 09b2b6e9 authored by bronze1man's avatar bronze1man Committed by Brad Fitzpatrick

net/http: remove unnecessary string replace operation in Cookie.String

Fixes #29135

Change-Id: I4c10b0395047775e8488b8b0f00f74a7fa01b86c
GitHub-Last-Rev: 120977040506794f00c74383289f913b1e0edd4a
GitHub-Pull-Request: golang/go#29728
Reviewed-on: https://go-review.googlesource.com/c/go/+/157777Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
parent 6b7114b9
......@@ -173,7 +173,7 @@ func (c *Cookie) String() string {
const extraCookieLength = 110
var b strings.Builder
b.Grow(len(c.Name) + len(c.Value) + len(c.Domain) + len(c.Path) + extraCookieLength)
b.WriteString(sanitizeCookieName(c.Name))
b.WriteString(c.Name)
b.WriteRune('=')
b.WriteString(sanitizeCookieValue(c.Value))
......
......@@ -127,6 +127,22 @@ var writeSetCookiesTests = []struct {
&Cookie{Name: "\t"},
``,
},
{
&Cookie{Name: "\r"},
``,
},
{
&Cookie{Name: "a\nb", Value: "v"},
``,
},
{
&Cookie{Name: "a\nb", Value: "v"},
``,
},
{
&Cookie{Name: "a\rb", Value: "v"},
``,
},
}
func TestWriteSetCookies(t *testing.T) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment