Fix setting of SameSite on cookies (#15989)

Fix #15972

Signed-off-by: Andrew Thornton <art27@cantab.net>

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
This commit is contained in:
zeripath 2021-05-27 02:01:07 +01:00 committed by GitHub
parent 568fe8c595
commit 6d39053711
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -149,7 +149,7 @@ func SetCookie(resp http.ResponseWriter, name string, value string, others ...in
if len(others) > 2 { if len(others) > 2 {
if v, ok := others[2].(string); ok && len(v) > 0 { if v, ok := others[2].(string); ok && len(v) > 0 {
cookie.Domain = v cookie.Domain = v
} else if v, ok := others[1].(func(*http.Cookie)); ok { } else if v, ok := others[2].(func(*http.Cookie)); ok {
v(&cookie) v(&cookie)
} }
} }
@ -170,7 +170,7 @@ func SetCookie(resp http.ResponseWriter, name string, value string, others ...in
if len(others) > 4 { if len(others) > 4 {
if v, ok := others[4].(bool); ok && v { if v, ok := others[4].(bool); ok && v {
cookie.HttpOnly = true cookie.HttpOnly = true
} else if v, ok := others[1].(func(*http.Cookie)); ok { } else if v, ok := others[4].(func(*http.Cookie)); ok {
v(&cookie) v(&cookie)
} }
} }
@ -179,7 +179,7 @@ func SetCookie(resp http.ResponseWriter, name string, value string, others ...in
if v, ok := others[5].(time.Time); ok { if v, ok := others[5].(time.Time); ok {
cookie.Expires = v cookie.Expires = v
cookie.RawExpires = v.Format(time.UnixDate) cookie.RawExpires = v.Format(time.UnixDate)
} else if v, ok := others[1].(func(*http.Cookie)); ok { } else if v, ok := others[5].(func(*http.Cookie)); ok {
v(&cookie) v(&cookie)
} }
} }