Permalink
Browse files

Tighten new_session option check.

git-svn-id: http://svn-commit.rubyonrails.org/rails/branches/1-2-pre-release@5822 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
1 parent 0120b22 commit 6dc5756d395ac591ee3d3c6c7e8c45dc3c8ddabb @jeremy jeremy committed Jan 1, 2007
Showing with 14 additions and 9 deletions.
  1. +14 −9 actionpack/lib/action_controller/cgi_process.rb
@@ -107,16 +107,21 @@ def session
@session = Hash.new
else
stale_session_check! do
- if session_options_with_string_keys['new_session'] == true
- @session = new_session
- else
- begin
+ case value = session_options_with_string_keys['new_session']
+ when true
+ @session = new_session
+ when false
+ begin
+ @session = CGI::Session.new(@cgi, session_options_with_string_keys)
+ # CGI::Session raises ArgumentError if 'new_session' == false
+ # and no session cookie or query param is present.
+ rescue ArgumentError
+ @session = Hash.new
+ end
+ when nil
@session = CGI::Session.new(@cgi, session_options_with_string_keys)
- # CGI::Session raises ArgumentError if 'new_session' == false
- # and no session cookie or query param is present.
- rescue ArgumentError
- @session = Hash.new
- end
+ else
+ raise ArgumentError, "Invalid new_session option: #{value}"
end
@session['__valid_session']
end

0 comments on commit 6dc5756

Please sign in to comment.