Skip to content
Browse files

Added HybridSerializer to upgrade existing marshal cookies (wip: need…

… tests)
  • Loading branch information...
1 parent 54641fa commit fafe8ece9d406cfbb197cc424baaa15a5772fae5 @chancancode chancancode committed Feb 5, 2014
Showing with 14 additions and 0 deletions.
  1. +14 −0 actionpack/lib/action_dispatch/middleware/cookies.rb
View
14 actionpack/lib/action_dispatch/middleware/cookies.rb
@@ -384,6 +384,18 @@ def self.dump(value)
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 @@ def serializer
Marshal
when :json
JsonSerializer
+ when :hybrid
+ HybridSerializer
else
serializer
end

0 comments on commit fafe8ec

Please sign in to comment.
Something went wrong with that request. Please try again.