瀏覽代碼

Fix setting of SameSite on cookies (#15989) (#15991)

Fix #15972

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

Co-authored-by: techknowlogick <techknowlogick@gitea.io>

Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
tags/v1.14.3
techknowlogick 3 年之前
父節點
當前提交
3a79f1190f
No account linked to committer's email address
共有 1 個文件被更改,包括 3 次插入3 次删除
  1. 3
    3
      modules/web/middleware/cookie.go

+ 3
- 3
modules/web/middleware/cookie.go 查看文件

@@ -149,7 +149,7 @@ func SetCookie(resp http.ResponseWriter, name string, value string, others ...in
if len(others) > 2 {
if v, ok := others[2].(string); ok && len(v) > 0 {
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)
}
}
@@ -170,7 +170,7 @@ func SetCookie(resp http.ResponseWriter, name string, value string, others ...in
if len(others) > 4 {
if v, ok := others[4].(bool); ok && v {
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)
}
}
@@ -179,7 +179,7 @@ func SetCookie(resp http.ResponseWriter, name string, value string, others ...in
if v, ok := others[5].(time.Time); ok {
cookie.Expires = v
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)
}
}

Loading…
取消
儲存