Permalink
Browse files

Array splitting strings on newlines is deprecated

  • Loading branch information...
1 parent 1850aea commit f5b4a9d02bc2292bae59e7b4fc028cce6edb91f7 @jeremy jeremy committed Apr 27, 2009
Showing with 15 additions and 4 deletions.
  1. +15 −4 actionpack/lib/action_dispatch/http/response.rb
@@ -245,9 +245,14 @@ def set_cookie(key, value)
# assert_equal 'AuthorOfNewPage', r.cookies['author']
def cookies
cookies = {}
- Array(headers['Set-Cookie']).each do |cookie|
- key, value = cookie.split(";").first.split("=").map { |v| Rack::Utils.unescape(v) }
- cookies[key] = value
+ if header = headers['Set-Cookie']
+ header = header.split("\n") if header.respond_to?(:to_str)
+ header.each do |cookie|
+ if pair = cookie.split(';').first
+ key, value = pair.split("=").map { |v| Rack::Utils.unescape(v) }
+ cookies[key] = value
+ end
+ end
end
cookies
end
@@ -305,7 +310,13 @@ def convert_language!
end
def convert_cookies!
- headers['Set-Cookie'] = Array(headers['Set-Cookie']).compact
+ headers['Set-Cookie'] =
+ if header = headers['Set-Cookie']
+ header = header.split("\n") if header.respond_to?(:to_str)
+ header.compact
+ else
+ []
+ end
end
end
end

0 comments on commit f5b4a9d

Please sign in to comment.