mirror of https://github.com/golang/go.git
net/http: check if strings.Cut was successful before trimming the cookie name
This commit is contained in:
parent
0ada047371
commit
368f50fcb4
|
|
@ -70,10 +70,10 @@ func readSetCookies(h Header) []*Cookie {
|
|||
}
|
||||
parts[0] = textproto.TrimString(parts[0])
|
||||
name, value, ok := strings.Cut(parts[0], "=")
|
||||
name = textproto.TrimString(name)
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
name = textproto.TrimString(name)
|
||||
if !isCookieNameValid(name) {
|
||||
continue
|
||||
}
|
||||
|
|
|
|||
|
|
@ -352,6 +352,8 @@ var readSetCookiesTests = []struct {
|
|||
Header{"Set-Cookie": {`special-8=","`}},
|
||||
[]*Cookie{{Name: "special-8", Value: ",", Raw: `special-8=","`}},
|
||||
},
|
||||
// Make sure we can properly read back the Set-Cookie headers
|
||||
// for names containing spaces:
|
||||
{
|
||||
Header{"Set-Cookie": {`special-9 =","`}},
|
||||
[]*Cookie{{Name: "special-9", Value: ",", Raw: `special-9 =","`}},
|
||||
|
|
|
|||
Loading…
Reference in New Issue