1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Space is not required for Set-Cookie header

This commit is contained in:
Yamagishi Kazutoshi 2013-06-27 05:59:16 +09:00
parent 37aaaa7e70
commit ce89251bb2
3 changed files with 34 additions and 1 deletions

View file

@ -1,3 +1,7 @@
* Ignore spaces around delimiter in Set-Cookie header.
*Yamagishi Kazutoshi*
* Remove deprecated Rails application fallback for integration testing, set
`ActionDispatch.test_app` instead.

View file

@ -57,7 +57,7 @@ module ActionDispatch
cookies = cookies.split("\n")
headers['Set-Cookie'] = cookies.map { |cookie|
if cookie !~ /;\s+secure(;|$)/i
if cookie !~ /;\s*secure\s*(;|$)/i
"#{cookie}; secure"
else
cookie

View file

@ -124,6 +124,35 @@ class SSLTest < ActionDispatch::IntegrationTest
response.headers['Set-Cookie'].split("\n")
end
def test_flag_cookies_as_secure_with_has_not_spaces_before
self.app = ActionDispatch::SSL.new(lambda { |env|
headers = {
'Content-Type' => "text/html",
'Set-Cookie' => "problem=def; path=/;secure; HttpOnly"
}
[200, headers, ["OK"]]
})
get "https://example.org/"
assert_equal ["problem=def; path=/;secure; HttpOnly"],
response.headers['Set-Cookie'].split("\n")
end
def test_flag_cookies_as_secure_with_has_not_spaces_after
self.app = ActionDispatch::SSL.new(lambda { |env|
headers = {
'Content-Type' => "text/html",
'Set-Cookie' => "problem=def; path=/; secure;HttpOnly"
}
[200, headers, ["OK"]]
})
get "https://example.org/"
assert_equal ["problem=def; path=/; secure;HttpOnly"],
response.headers['Set-Cookie'].split("\n")
end
def test_flag_cookies_as_secure_with_ignore_case
self.app = ActionDispatch::SSL.new(lambda { |env|
headers = {