diff options
author | Godfrey Chan <godfreykfc@gmail.com> | 2014-02-05 03:17:28 -0800 |
---|---|---|
committer | Godfrey Chan <godfreykfc@gmail.com> | 2014-02-11 01:54:16 -0800 |
commit | fafe8ece9d406cfbb197cc424baaa15a5772fae5 (patch) | |
tree | 829c979f30767bd80825c9485d5ae9584d25cae8 /actionpack/lib | |
parent | 54641fa2e3d248bf89e1a9954e06d6bbefa7bafa (diff) | |
download | rails-fafe8ece9d406cfbb197cc424baaa15a5772fae5.tar.gz rails-fafe8ece9d406cfbb197cc424baaa15a5772fae5.tar.bz2 rails-fafe8ece9d406cfbb197cc424baaa15a5772fae5.zip |
Added HybridSerializer to upgrade existing marshal cookies (wip: need tests)
Diffstat (limited to 'actionpack/lib')
-rw-r--r-- | actionpack/lib/action_dispatch/middleware/cookies.rb | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/actionpack/lib/action_dispatch/middleware/cookies.rb b/actionpack/lib/action_dispatch/middleware/cookies.rb index 7e8a395d93..fa94f9c9e4 100644 --- a/actionpack/lib/action_dispatch/middleware/cookies.rb +++ b/actionpack/lib/action_dispatch/middleware/cookies.rb @@ -384,6 +384,18 @@ module ActionDispatch end end + class HybridSerializer < JsonSerializer + MARSHAL_SIGNATURE = "\x04\x08".freeze + + def self.load(value) + if value.start_with?(MARSHAL_SIGNATURE) + Marshal.load(value) + else + super + end + end + end + module SerializedCookieJars protected def serializer @@ -393,6 +405,8 @@ module ActionDispatch Marshal when :json JsonSerializer + when :hybrid + HybridSerializer else serializer end |