Permalink
Browse files

Accessing nonexistant cookies through the signed jar should not raise…

… an exception
  • Loading branch information...
1 parent 6d1494c commit 1229ef7bf329cd09ed0a1bbe39530ccc69795995 @dhh dhh committed Dec 16, 2009
Showing with 8 additions and 1 deletion.
  1. +3 −1 actionpack/lib/action_controller/cookies.rb
  2. +5 −0 actionpack/test/controller/cookie_test.rb
@@ -168,7 +168,9 @@ def initialize(parent_jar)
end
def [](name)
- @verifier.verify(@parent_jar[name])
+ if value = @parent_jar[name]
+ @verifier.verify(value)
+ end
end
def []=(key, options)
@@ -157,6 +157,11 @@ def test_signed_cookie
assert_equal 45, @controller.send(:cookies).signed[:user_id]
end
+ def test_accessing_nonexistant_signed_cookie_should_not_raise_an_invalid_signature
+ get :set_signed_cookie
+ assert_nil @controller.send(:cookies).signed[:non_existant_attribute]
+ end
+
def test_permanent_signed_cookie
get :set_permanent_signed_cookie
assert_match %r(#{20.years.from_now.year}), @response.headers["Set-Cookie"].first

0 comments on commit 1229ef7

Please sign in to comment.