1
0
mirror of https://github.com/golang/go synced 2024-11-17 13:54:46 -07:00

net/http: useless string replace operation in Cookie.String. Fixes #29135

This commit is contained in:
bronze1man 2019-01-14 22:47:14 +08:00
parent 4e8aaf6b22
commit 1209770405
2 changed files with 9 additions and 1 deletions

View File

@ -169,7 +169,7 @@ func (c *Cookie) String() string {
return ""
}
var b strings.Builder
b.WriteString(sanitizeCookieName(c.Name))
b.WriteString(c.Name)
b.WriteRune('=')
b.WriteString(sanitizeCookieValue(c.Value))

View File

@ -127,6 +127,14 @@ var writeSetCookiesTests = []struct {
&Cookie{Name: "\t"},
``,
},
{
&Cookie{Name: "\r"},
``,
},
{
&Cookie{Name: "\n"},
``,
},
}
func TestWriteSetCookies(t *testing.T) {