diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2020-05-28 09:25:08 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-28 09:25:08 -0700 |
commit | 846e7662885985df512e360d5801395878a553e3 (patch) | |
tree | 3f46a0de0e5f20d69e86ada803ac1fb0aa4cdb72 | |
parent | c8538197e253ceb8adabd0c395638c07a09c8e0d (diff) | |
parent | ffab89c3ae50d252151a4b1a62f2f5aaaa712755 (diff) | |
download | rack-846e7662885985df512e360d5801395878a553e3.tar.gz |
Merge pull request #1667 from jeremyevans/json-cookie-1666
Fix using Rack::Session::Cookie with coder: Rack::Session::Cookie::Base64::{JSON,Zip}
-rw-r--r-- | CHANGELOG.md | 1 | ||||
-rw-r--r-- | lib/rack/session/abstract/id.rb | 7 | ||||
-rw-r--r-- | test/spec_session_abstract_persisted_secure_secure_session_hash.rb | 9 |
3 files changed, 16 insertions, 1 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index a115d7e1..e91cafde 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ All notable changes to this project will be documented in this file. For info on ### Fixed +- Fix using Rack::Session::Cookie with coder: Rack::Session::Cookie::Base64::{JSON,Zip}. ([#1666](https://github.com/rack/rack/issues/1666), [@jeremyevans](https://github.com/jeremyevans)) - Avoid NoMethodError when accessing Rack::Session::Cookie without requiring delegate first. ([#1610](https://github.com/rack/rack/issues/1610), [@onigra](https://github.com/onigra)) - Handle cookies with values that end in '=' ([#1645](https://github.com/rack/rack/pull/1645), [@lukaso](https://github.com/lukaso)) diff --git a/lib/rack/session/abstract/id.rb b/lib/rack/session/abstract/id.rb index 638bd3b3..bbc79668 100644 --- a/lib/rack/session/abstract/id.rb +++ b/lib/rack/session/abstract/id.rb @@ -455,7 +455,12 @@ module Rack def [](key) if key == "session_id" load_for_read! - id.public_id if id + case id + when SessionId + id.public_id + else + id + end else super end diff --git a/test/spec_session_abstract_persisted_secure_secure_session_hash.rb b/test/spec_session_abstract_persisted_secure_secure_session_hash.rb index 1a007eb4..bbb8a900 100644 --- a/test/spec_session_abstract_persisted_secure_secure_session_hash.rb +++ b/test/spec_session_abstract_persisted_secure_secure_session_hash.rb @@ -44,6 +44,15 @@ describe Rack::Session::Abstract::PersistedSecure::SecureSessionHash do @hash = Rack::Session::Abstract::PersistedSecure::SecureSessionHash.new(store, nil) assert_nil hash['session_id'] end + + it "returns value for non SessionId 'session_id' key" do + store = @store.new + def store.load_session(req) + ["id", {}] + end + @hash = Rack::Session::Abstract::PersistedSecure::SecureSessionHash.new(store, nil) + assert_equal "id", hash['session_id'] + end end describe "#fetch" do |