@@ -79,7 +79,7 @@ func ParseCookie(line string) ([]*Cookie, error) {
79
79
if ! found {
80
80
return nil , errEqualNotFoundInCookie
81
81
}
82
- if ! isCookieNameValid (name ) {
82
+ if ! isToken (name ) {
83
83
return nil , errInvalidCookieName
84
84
}
85
85
value , quoted , found := parseCookieValue (value , true )
@@ -104,7 +104,7 @@ func ParseSetCookie(line string) (*Cookie, error) {
104
104
return nil , errEqualNotFoundInCookie
105
105
}
106
106
name = textproto .TrimString (name )
107
- if ! isCookieNameValid (name ) {
107
+ if ! isToken (name ) {
108
108
return nil , errInvalidCookieName
109
109
}
110
110
value , quoted , ok := parseCookieValue (value , true )
@@ -225,7 +225,7 @@ func SetCookie(w ResponseWriter, cookie *Cookie) {
225
225
// header (if other fields are set).
226
226
// If c is nil or c.Name is invalid, the empty string is returned.
227
227
func (c * Cookie ) String () string {
228
- if c == nil || ! isCookieNameValid (c .Name ) {
228
+ if c == nil || ! isToken (c .Name ) {
229
229
return ""
230
230
}
231
231
// extraCookieLength derived from typical length of cookie attributes
@@ -295,7 +295,7 @@ func (c *Cookie) Valid() error {
295
295
if c == nil {
296
296
return errors .New ("http: nil Cookie" )
297
297
}
298
- if ! isCookieNameValid (c .Name ) {
298
+ if ! isToken (c .Name ) {
299
299
return errors .New ("http: invalid Cookie.Name" )
300
300
}
301
301
if ! c .Expires .IsZero () && ! validCookieExpires (c .Expires ) {
@@ -349,7 +349,7 @@ func readCookies(h Header, filter string) []*Cookie {
349
349
}
350
350
name , val , _ := strings .Cut (part , "=" )
351
351
name = textproto .TrimString (name )
352
- if ! isCookieNameValid (name ) {
352
+ if ! isToken (name ) {
353
353
continue
354
354
}
355
355
if filter != "" && filter != name {
@@ -526,10 +526,3 @@ func parseCookieValue(raw string, allowDoubleQuote bool) (value string, quoted,
526
526
}
527
527
return raw , quoted , true
528
528
}
529
-
530
- func isCookieNameValid (raw string ) bool {
531
- if raw == "" {
532
- return false
533
- }
534
- return strings .IndexFunc (raw , isNotToken ) < 0
535
- }
0 commit comments