This project is archived and is in readonly mode.
Override content type when rendering default error file
Reported by Brady Bouchard | November 26th, 2008 @ 08:35 AM | in 2.x
If a template is rendered with a content type other than 'text/html', when an exception is raised and considered a non-local request, the default error file (500.html) will be rendered with the specified content type rather than 'text/html'. This can cause wonkiness in some browsers.
For example:
class DummyController < ApplicationController
def index
render :inline => "<%= response.bad_method %>", :content_type => 'text/plain'
end
end
When the above method is accessed, the default file (500.html) will be rendered with a content type of 'text/plain', which will cause browsers such as Safari to render the page as plain text rather than HTML. Ugly.
A fix is attached. I spent quite a bit of time trying to come up with a test, but it looks like a test would mean adding quite a bit of code to either rescue_test.rb or render_test.rb (since it requires both the set up code for rendering as well as rescuing). If anyone can code one up, that would be great - and/or point me in the right direction.
Comments and changes to this ticket
-
josh December 15th, 2008 @ 09:31 PM
- Tag set to bug, content_type, patch, render
- Assigned user set to josh
-
Repository December 17th, 2008 @ 04:22 PM
- State changed from new to resolved
(from [33f76bb25a973a4707437064e2f963c521413fcb]) Ensure error file is sent with a 'text/html' content type [#1478 state:resolved]
Signed-off-by: Joshua Peek josh@joshpeek.com http://github.com/rails/rails/co...
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
<h2 style="font-size: 14px">Tickets have moved to Github</h2>
The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>
People watching this ticket
Attachments
Tags
Referenced by
- 1478 Override content type when rendering default error file (from [33f76bb25a973a4707437064e2f963c521413fcb]) Ensure ...