Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

merge [7978] from edge

git-svn-id: http://svn-commit.rubyonrails.org/rails/branches/1-2-stable@7979 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
commit 5285270dde50cd83239b70a23139319dd8d9e302 1 parent 257d860
risk danger olson technoweenie authored
2  actionpack/CHANGELOG
View
@@ -1,3 +1,5 @@
+* Ensure that cookies handle array values correctly. Closes #9937 [queso]
+
*1.13.5* (October 12th, 2007)
* Backport: allow array and hash query parameters. Array route parameters are converted/to/a/path as before. #6765, #7047, #7462 [bgipsy, Jeremy McAnally, Dan Kubb, brendan, Diego Algorta Casamayou]
5 actionpack/lib/action_controller/cookies.rb
View
@@ -47,7 +47,10 @@ def initialize(controller)
# Returns the value of the cookie by +name+ -- or nil if no such cookie exists. You set new cookies using either the cookie method
# or cookies[]= (for simple name/value cookies without options).
def [](name)
- @cookies[name.to_s].value.first if @cookies[name.to_s] && @cookies[name.to_s].respond_to?(:value)
+ cookie = @cookies[name.to_s]
+ if cookie && cookie.respond_to?(:value)
+ cookie.size > 1 ? cookie.value : cookie.value.to_s
+ end
end
def []=(name, options)
10 actionpack/test/controller/cookie_test.rb
View
@@ -22,7 +22,7 @@ def set_multiple_cookies
cookies["user_name"] = { "value" => "david", "expires" => Time.local(2005, 10, 10) }
cookies["login"] = "XJ-122"
end
-
+
def access_frozen_cookies
cookies["will"] = "work"
end
@@ -91,6 +91,14 @@ def test_cookiejar_accessor
assert_equal nil, jar["something_else"]
end
+ def test_cookiejar_accessor_with_array_value
+ a = %w{1 2 3}
+ @request.cookies["pages"] = CGI::Cookie.new("name" => "pages", "value" => a, "expires" => Time.local(2025, 10, 10))
+ @controller.request = @request
+ jar = ActionController::CookieJar.new(@controller)
+ assert_equal a, jar["pages"]
+ end
+
def test_delete_cookie_with_path
get :delete_cookie_with_path
assert_equal "/beaten", @response.headers["cookie"].first.path
Please sign in to comment.
Something went wrong with that request. Please try again.