diff options
author | Andrew White <andrew.white@unboxedconsulting.com> | 2016-02-16 06:02:42 +0000 |
---|---|---|
committer | Andrew White <andrew.white@unboxedconsulting.com> | 2016-02-16 06:02:42 +0000 |
commit | fd8b6c4bb5768cebf6499e7e87d22cebd1b82347 (patch) | |
tree | c4a51a3a8dda9d200285eb0c54546f54a58cc752 /actionpack/lib/action_dispatch | |
parent | 156c2cb571af8c2049e61c50232084a9351f428b (diff) | |
parent | 89df021375564fd613de646c53fa90b2d1eb7fb1 (diff) | |
download | rails-fd8b6c4bb5768cebf6499e7e87d22cebd1b82347.tar.gz rails-fd8b6c4bb5768cebf6499e7e87d22cebd1b82347.tar.bz2 rails-fd8b6c4bb5768cebf6499e7e87d22cebd1b82347.zip |
Merge pull request #22828 from ma2gedev/should-escape-cookie
A cookie value is incorrect if value contains an escapable string in Rails 5 ActionController::TestCase
Diffstat (limited to 'actionpack/lib/action_dispatch')
-rw-r--r-- | actionpack/lib/action_dispatch/middleware/cookies.rb | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/actionpack/lib/action_dispatch/middleware/cookies.rb b/actionpack/lib/action_dispatch/middleware/cookies.rb index 3477aa8b29..f2f3150b56 100644 --- a/actionpack/lib/action_dispatch/middleware/cookies.rb +++ b/actionpack/lib/action_dispatch/middleware/cookies.rb @@ -2,6 +2,7 @@ require 'active_support/core_ext/hash/keys' require 'active_support/key_generator' require 'active_support/message_verifier' require 'active_support/json' +require 'rack/utils' module ActionDispatch class Request @@ -337,7 +338,7 @@ module ActionDispatch end def to_header - @cookies.map { |k,v| "#{k}=#{v}" }.join ';' + @cookies.map { |k,v| "#{escape(k)}=#{escape(v)}" }.join '; ' end def handle_options(options) #:nodoc: @@ -419,6 +420,10 @@ module ActionDispatch private + def escape(string) + ::Rack::Utils.escape(string) + end + def make_set_cookie_header(header) header = @set_cookies.inject(header) { |m, (k, v)| if write_cookie?(v) |