diff options
| author | shugo <shugo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2004-08-24 08:31:22 +0000 |
|---|---|---|
| committer | shugo <shugo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2004-08-24 08:31:22 +0000 |
| commit | 99b51818fc3803c62cacbb2a744e589063ead323 (patch) | |
| tree | 0dbf353d9ea9290de1f88e37480226322dee3c11 /lib | |
| parent | 386d9b3606fb52d8c1e9530e9bb899e7f1459c52 (diff) | |
| download | ruby-99b51818fc3803c62cacbb2a744e589063ead323.tar.gz ruby-99b51818fc3803c62cacbb2a744e589063ead323.tar.xz ruby-99b51818fc3803c62cacbb2a744e589063ead323.zip | |
* lib/cgi/session.rb (CGI::Session::FileStore#initialize): do not
use a session id as a filename. (backported from HEAD)
* lib/cgi/session/pstore.rb (CGI::Session::PStore#initialize): ditto.
* lib/cgi/session/pstore.rb (CGI::Session::PStore#initialize): use
Dir::tmpdir. (backported from HEAD)
git-svn-id: http://svn.ruby-lang.org/repos/ruby/branches/ruby_1_8@6816 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/cgi/session.rb | 11 | ||||
| -rw-r--r-- | lib/cgi/session/pstore.rb | 13 |
2 files changed, 7 insertions, 17 deletions
diff --git a/lib/cgi/session.rb b/lib/cgi/session.rb index a5afb7e3e..c320ac9c4 100644 --- a/lib/cgi/session.rb +++ b/lib/cgi/session.rb @@ -331,10 +331,6 @@ class CGI # user is responsible for converting other types to Strings when # storing and from Strings when retrieving. class FileStore - def check_id(id) #:nodoc: - /[^0-9a-zA-Z]/ =~ id.to_s ? false : true - end - # Create a new FileStore instance. # # This constructor is used internally by CGI::Session. The @@ -361,10 +357,9 @@ class CGI dir = option['tmpdir'] || Dir::tmpdir prefix = option['prefix'] || '' id = session.session_id - unless check_id(id) - raise ArgumentError, "session_id `%s' is invalid" % id - end - @path = dir+"/"+prefix+id.dup.untaint + require 'digest/md5' + md5 = Digest::MD5.hexdigest(id)[0,16] + @path = dir+"/"+prefix+md5 unless File::exist? @path @hash = {} end diff --git a/lib/cgi/session/pstore.rb b/lib/cgi/session/pstore.rb index f46dd5739..033acc324 100644 --- a/lib/cgi/session/pstore.rb +++ b/lib/cgi/session/pstore.rb @@ -31,10 +31,6 @@ class CGI # library file pstore.rb. Session data is marshalled and stored # in a file. File locking and transaction services are provided. class PStore - def check_id(id) #:nodoc: - /[^0-9a-zA-Z]/ =~ id.to_s ? false : true - end - # Create a new CGI::Session::PStore instance # # This constructor is used internally by CGI::Session. The @@ -58,13 +54,12 @@ class CGI # This session's PStore file will be created if it does # not exist, or opened if it does. def initialize session, option={} - dir = option['tmpdir'] || ENV['TMP'] || '/tmp' + dir = option['tmpdir'] || Dir::tmpdir prefix = option['prefix'] || '' id = session.session_id - unless check_id(id) - raise ArgumentError, "session_id `%s' is invalid" % id - end - path = dir+"/"+prefix+id + require 'digest/md5' + md5 = Digest::MD5.hexdigest(id)[0,16] + path = dir+"/"+prefix+md5 path.untaint unless File::exist? path @hash = {} |
