From c877857d59554d78dbf45f5f9fcaafb8badec4e2 Mon Sep 17 00:00:00 2001 From: Doug McInnes Date: Tue, 3 Feb 2009 18:37:55 -0800 Subject: Fix for TestResponse.cookies returning cookies unescaped [#1867 state:resolved] Signed-off-by: David Heinemeier Hansson --- actionpack/CHANGELOG | 5 +++++ actionpack/lib/action_controller/test_process.rb | 2 +- actionpack/test/controller/cookie_test.rb | 10 ++++++++++ 3 files changed, 16 insertions(+), 1 deletion(-) (limited to 'actionpack') diff --git a/actionpack/CHANGELOG b/actionpack/CHANGELOG index 8c9486cc63..11ee1c1059 100644 --- a/actionpack/CHANGELOG +++ b/actionpack/CHANGELOG @@ -1,3 +1,8 @@ +*Edge* + +* Fixed that TestResponse.cookies was returning cookies unescaped #1867 [Doug McInnes] + + *2.3.2 [Final] (March 15, 2009)* * Fixed that redirection would just log the options, not the final url (which lead to "Redirected to #") [DHH] diff --git a/actionpack/lib/action_controller/test_process.rb b/actionpack/lib/action_controller/test_process.rb index 93a3f9d874..fbc1b519bf 100644 --- a/actionpack/lib/action_controller/test_process.rb +++ b/actionpack/lib/action_controller/test_process.rb @@ -258,7 +258,7 @@ module ActionController #:nodoc: def cookies cookies = {} Array(headers['Set-Cookie']).each do |cookie| - key, value = cookie.split(";").first.split("=") + key, value = cookie.split(";").first.split("=").map {|val| Rack::Utils.unescape(val)} cookies[key] = value end cookies diff --git a/actionpack/test/controller/cookie_test.rb b/actionpack/test/controller/cookie_test.rb index 657be3c4e4..f7d97e160a 100644 --- a/actionpack/test/controller/cookie_test.rb +++ b/actionpack/test/controller/cookie_test.rb @@ -6,6 +6,10 @@ class CookieTest < ActionController::TestCase cookies["user_name"] = "david" end + def set_with_with_escapable_characters + cookies["that & guy"] = "foo & bar => baz" + end + def authenticate_for_fourteen_days cookies["user_name"] = { "value" => "david", "expires" => Time.utc(2005, 10, 10,5) } end @@ -53,6 +57,12 @@ class CookieTest < ActionController::TestCase assert_equal({"user_name" => "david"}, @response.cookies) end + def test_setting_with_escapable_characters + get :set_with_with_escapable_characters + assert_equal ["that+%26+guy=foo+%26+bar+%3D%3E+baz; path=/"], @response.headers["Set-Cookie"] + assert_equal({"that & guy" => "foo & bar => baz"}, @response.cookies) + end + def test_setting_cookie_for_fourteen_days get :authenticate_for_fourteen_days assert_equal ["user_name=david; path=/; expires=Mon, 10-Oct-2005 05:00:00 GMT"], @response.headers["Set-Cookie"] -- cgit v1.2.3