module ActionDispatch::Cookies::SerializedCookieJars
def check_for_overflow!(name, options)
def check_for_overflow!(name, options) if options[:value].bytesize > MAX_COOKIE_SIZE raise CookieOverflow, "#{name} cookie overflowed with size #{options[:value].bytesize} bytes" end end
def commit(name, options)
def commit(name, options) options[:value] = serializer.dump(options[:value]) end
def digest
def digest request.cookies_digest || "SHA1" end
def parse(name, dumped, force_reserialize: false, **)
def parse(name, dumped, force_reserialize: false, **) if dumped begin value = serializer.load(dumped) rescue StandardError return end self[name] = { value: value } if force_reserialize || reserialize?(dumped) value end end
def reserialize?(dumped)
def reserialize?(dumped) serializer.is_a?(ActiveSupport::Messages::SerializerWithFallback) && serializer != ActiveSupport::Messages::SerializerWithFallback[:marshal] && !serializer.dumped?(dumped) end
def serializer
def serializer @serializer ||= case request.cookies_serializer when nil ActiveSupport::Messages::SerializerWithFallback[:marshal] when :hybrid ActiveSupport::Messages::SerializerWithFallback[:json_allow_marshal] when Symbol ActiveSupport::Messages::SerializerWithFallback[request.cookies_serializer] else request.cookies_serializer end end