mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Removed single space padding from empty response body.
`render nothing: true` or rendering a `nil` body no longer add a single space to the response body. The old behavior was added as a workaround for a bug in an early version of Safari, where the HTTP headers are not returned correctly if the response body has a 0-length. This is been fixed since and the workaround is no longer necessary. Use `render body: ' '` if the old behavior is desired.
This commit is contained in:
parent
6e76031e8f
commit
013c74d645
6 changed files with 32 additions and 22 deletions
|
@ -1,3 +1,17 @@
|
|||
* `render nothing: true` or rendering a `nil` body no longer add a single
|
||||
space to the response body.
|
||||
|
||||
The old behavior was added as a workaround for a bug in an early version of
|
||||
Safari, where the HTTP headers are not returned correctly if the response
|
||||
body has a 0-length. This is been fixed since and the workaround is no
|
||||
longer necessary.
|
||||
|
||||
Use `render body: ' '` if the old behavior is desired.
|
||||
|
||||
See #14883 for details.
|
||||
|
||||
*Godfrey Chan*
|
||||
|
||||
* Prepend a JS comment to JSONP callbacks. Addresses CVE-2014-4671
|
||||
("Rosetta Flash")
|
||||
|
||||
|
|
|
@ -67,8 +67,8 @@ module ActionController
|
|||
options[:html] = ERB::Util.html_escape(options[:html])
|
||||
end
|
||||
|
||||
if options.delete(:nothing) || _any_render_format_is_nil?(options)
|
||||
options[:body] = " "
|
||||
if options.delete(:nothing)
|
||||
options[:body] = nil
|
||||
end
|
||||
|
||||
if options[:status]
|
||||
|
@ -86,10 +86,6 @@ module ActionController
|
|||
end
|
||||
end
|
||||
|
||||
def _any_render_format_is_nil?(options)
|
||||
RENDER_FORMATS_IN_PRIORITY.any? { |format| options.key?(format) && options[format].nil? }
|
||||
end
|
||||
|
||||
# Process controller specific options, as status, content-type and location.
|
||||
def _process_options(options) #:nodoc:
|
||||
status, content_type, location = options.values_at(:status, :content_type, :location)
|
||||
|
|
|
@ -111,17 +111,17 @@ module RenderBody
|
|||
assert_status 404
|
||||
end
|
||||
|
||||
test "rendering body with nil returns an empty body padded for Safari" do
|
||||
test "rendering body with nil returns an empty body" do
|
||||
get "/render_body/with_layout/with_nil"
|
||||
|
||||
assert_body " "
|
||||
assert_body ""
|
||||
assert_status 200
|
||||
end
|
||||
|
||||
test "Rendering body with nil and custom status code returns an empty body padded for Safari and the status" do
|
||||
test "Rendering body with nil and custom status code returns an empty body and the status" do
|
||||
get "/render_body/with_layout/with_nil_and_status"
|
||||
|
||||
assert_body " "
|
||||
assert_body ""
|
||||
assert_status 403
|
||||
end
|
||||
|
||||
|
|
|
@ -114,17 +114,17 @@ module RenderHtml
|
|||
assert_status 404
|
||||
end
|
||||
|
||||
test "rendering text with nil returns an empty body padded for Safari" do
|
||||
test "rendering text with nil returns an empty body" do
|
||||
get "/render_html/with_layout/with_nil"
|
||||
|
||||
assert_body " "
|
||||
assert_body ""
|
||||
assert_status 200
|
||||
end
|
||||
|
||||
test "Rendering text with nil and custom status code returns an empty body padded for Safari and the status" do
|
||||
test "Rendering text with nil and custom status code returns an empty body and the status" do
|
||||
get "/render_html/with_layout/with_nil_and_status"
|
||||
|
||||
assert_body " "
|
||||
assert_body ""
|
||||
assert_status 403
|
||||
end
|
||||
|
||||
|
|
|
@ -106,17 +106,17 @@ module RenderPlain
|
|||
assert_status 404
|
||||
end
|
||||
|
||||
test "rendering text with nil returns an empty body padded for Safari" do
|
||||
test "rendering text with nil returns an empty body" do
|
||||
get "/render_plain/with_layout/with_nil"
|
||||
|
||||
assert_body " "
|
||||
assert_body ""
|
||||
assert_status 200
|
||||
end
|
||||
|
||||
test "Rendering text with nil and custom status code returns an empty body padded for Safari and the status" do
|
||||
test "Rendering text with nil and custom status code returns an empty body and the status" do
|
||||
get "/render_plain/with_layout/with_nil_and_status"
|
||||
|
||||
assert_body " "
|
||||
assert_body ""
|
||||
assert_status 403
|
||||
end
|
||||
|
||||
|
|
|
@ -106,17 +106,17 @@ module RenderText
|
|||
assert_status 404
|
||||
end
|
||||
|
||||
test "rendering text with nil returns an empty body padded for Safari" do
|
||||
test "rendering text with nil returns an empty body" do
|
||||
get "/render_text/with_layout/with_nil"
|
||||
|
||||
assert_body " "
|
||||
assert_body ""
|
||||
assert_status 200
|
||||
end
|
||||
|
||||
test "Rendering text with nil and custom status code returns an empty body padded for Safari and the status" do
|
||||
test "Rendering text with nil and custom status code returns an empty body and the status" do
|
||||
get "/render_text/with_layout/with_nil_and_status"
|
||||
|
||||
assert_body " "
|
||||
assert_body ""
|
||||
assert_status 403
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue