summaryrefslogtreecommitdiff
path: root/lib/cgi
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-11-22 15:29:52 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-11-22 15:29:52 +0000
commit39080991ab143d36afd40f3f6f547de571f98df7 (patch)
tree3bd7aa4308df0efc028494bc5e2965128a9b5991 /lib/cgi
parente2242e7e2a3df11808445a87f091e43e9ce37963 (diff)
* file.c (rb_file_chown): integer conversion should be prior to
GetOpenFile(). [ruby-dev:24947] * file.c (rb_file_truncate): ditto. * file.c (rb_file_s_truncate): ditto. * dir.c (dir_seek): use NUM2OFFT(). * misc/ruby-mode.el (ruby-non-block-do-re): [ruby-core:03719] * dir.c (dir_seek): should retrieve dir_data after NUM2INT(). [ruby-dev:24941] * string.c (rb_str_splice): should place index wrapping after possible modification. [ruby-dev:24940] * eval.c (error_print): nicer traceback at interrupt. [ruby-core:03774] * string.c (str_gsub): internal buffer should not be listed by ObjectSpace.each_object() by String#gsub. [ruby-dev:24931] * lib/cgi/session.rb (CGI::Session::FileStore::initialize): raise exception if data corresponding to session specified from the client does not exist. * string.c (str_gsub): internal buffer should not be listed by ObjectSpace.each_object(). [ruby-dev:24919] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@7354 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/cgi')
-rw-r--r--lib/cgi/session.rb17
-rw-r--r--lib/cgi/session/pstore.rb5
2 files changed, 18 insertions, 4 deletions
diff --git a/lib/cgi/session.rb b/lib/cgi/session.rb
index 66ab8fd67e..0342f84d84 100644
--- a/lib/cgi/session.rb
+++ b/lib/cgi/session.rb
@@ -156,7 +156,7 @@ class CGI
class Session
# The id of this session.
- attr_reader :session_id
+ attr_reader :session_id, :new_session
def Session::callback(dbman) #:nodoc:
Proc.new{
@@ -170,7 +170,7 @@ class CGI
# a random number, and a constant string. This routine
# is used internally for automatically generated
# session ids.
- def Session::create_new_id
+ def create_new_id
require 'digest/md5'
md5 = Digest::MD5::new
now = Time::now
@@ -179,8 +179,10 @@ class CGI
md5.update(String(rand(0)))
md5.update(String($$))
md5.update('foobar')
+ @new_session = true
md5.hexdigest[0,16]
end
+ private :create_new_id
# Create a new CGI::Session object for +request+.
#
@@ -239,6 +241,7 @@ class CGI
# end
#
def initialize(request, option={})
+ @new_session = false
session_key = option['session_key'] || '_session_id'
id = option['session_id']
unless id
@@ -367,6 +370,9 @@ class CGI
md5 = Digest::MD5.hexdigest(id)[0,16]
@path = dir+"/"+prefix+md5+suffix
unless File::exist? @path
+ unless session.new_session
+ raise RuntimeError, "uninitialized session"
+ end
@hash = {}
end
end
@@ -433,7 +439,12 @@ class CGI
# currently recognised.
def initialize(session, option=nil)
@session_id = session.session_id
- GLOBAL_HASH_TABLE[@session_id] ||= {}
+ unless GLOBAL_HASH_TABLE.key?(@session_id)
+ unless session.new_session
+ raise RuntimeError, "uninitialized session"
+ end
+ GLOBAL_HASH_TABLE[@session_id] = {}
+ end
end
# Restore session state.
diff --git a/lib/cgi/session/pstore.rb b/lib/cgi/session/pstore.rb
index 10f3e8f75f..e65a2a97db 100644
--- a/lib/cgi/session/pstore.rb
+++ b/lib/cgi/session/pstore.rb
@@ -61,7 +61,10 @@ class CGI
md5 = Digest::MD5.hexdigest(id)[0,16]
path = dir+"/"+prefix+md5
path.untaint
- unless File::exist? path
+ unless File::exist?(path)
+ unless session.new_session
+ raise RuntimeError, "uninitialized session"
+ end
@hash = {}
end
@p = ::PStore.new(path)