File tree Expand file tree Collapse file tree 2 files changed +7
-2
lines changed
Expand file tree Collapse file tree 2 files changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -206,13 +206,15 @@ def create_new_id
206206 # on Unix systems).
207207 # prefix:: the prefix to add to the session id when generating
208208 # the filename for this session's FileStore file.
209- # Defaults to "cgi_sid_" .
209+ # Defaults to the empty string .
210210 # suffix:: the prefix to add to the session id when generating
211211 # the filename for this session's FileStore file.
212212 # Defaults to the empty string.
213213 # digest:: the digest algorithm to hash the session id when
214214 # generating the filename for this session's FileStore
215215 # file. Defaults to "SHA256".
216+ # length:: the length of the session id part of the filestore,
217+ # excluding +prefix+ and +suffix+ parts. Defaults to 16.
216218 def new_store_file ( option = { } ) # :nodoc:
217219 dir = option [ 'tmpdir' ] || Dir ::tmpdir
218220 prefix = option [ 'prefix' ]
@@ -222,7 +224,7 @@ def new_store_file(option={}) # :nodoc:
222224 require 'digest'
223225 algorithm = Digest ( algorithm )
224226 end
225- digest = algorithm . hexdigest ( session_id ) [ 0 , 16 ]
227+ digest = algorithm . hexdigest ( session_id ) [ 0 , option [ 'length' ] || 16 ]
226228 path = dir +"/"
227229 path << prefix if prefix
228230 path << digest
Original file line number Diff line number Diff line change @@ -177,6 +177,9 @@ def test_cgi_session_filestore_path
177177 path_sha512 = session_file_store_path ( "tmpdir" => @session_dir , "session_id" => session_id , "digest" => "SHA512" )
178178 assert_session_filestore_path ( path_default )
179179 assert_not_equal path_sha512 , path_default
180+ path_long = session_file_store_path ( "tmpdir" => @session_dir , "session_id" => session_id , "length" => 32 )
181+ assert_equal path_default . length +16 , path_long . length
182+ assert_send [ path_long , :start_with? , path_default ]
180183
181184 path = session_file_store_path ( "tmpdir" => @session_dir , "session_id" => session_id , "digest" => Digest ::SHA256 )
182185 assert_equal path_default , path
You can’t perform that action at this time.
0 commit comments