diff --git a/actionpack/lib/action_dispatch/middleware/templates/rescues/_message_and_suggestions.html.erb b/actionpack/lib/action_dispatch/middleware/templates/rescues/_message_and_suggestions.html.erb
index 8d43478c6e..260985a7de 100644
--- a/actionpack/lib/action_dispatch/middleware/templates/rescues/_message_and_suggestions.html.erb
+++ b/actionpack/lib/action_dispatch/middleware/templates/rescues/_message_and_suggestions.html.erb
@@ -1,5 +1,7 @@
<% if exception.respond_to?(:original_message) && exception.respond_to?(:corrections) %>
-
<%= h exception.original_message %>
+
+ <%= simple_format h(exception.original_message), { class: "message" }, wrapper_tag: "div" %>
+
<%
# The 'did_you_mean' gem can raise exceptions when calling #corrections on
# the exception. If it does there are no corrections to show.
@@ -14,5 +16,7 @@
<% end %>
<% else %>
- <%= h exception.message %>
+
+ <%= simple_format h(exception.message), { class: "message" }, wrapper_tag: "div" %>
+
<% end %>
diff --git a/actionpack/lib/action_dispatch/middleware/templates/rescues/layout.erb b/actionpack/lib/action_dispatch/middleware/templates/rescues/layout.erb
index 21a12e5048..b3a4182ac7 100644
--- a/actionpack/lib/action_dispatch/middleware/templates/rescues/layout.erb
+++ b/actionpack/lib/action_dispatch/middleware/templates/rescues/layout.erb
@@ -49,6 +49,18 @@
line-height: 25px;
}
+ .exception-message {
+ padding: 8px 0;
+ }
+
+ .exception-message .message{
+ margin-bottom: 8px;
+ line-height: 25px;
+ font-size: 1.5em;
+ font-weight: bold;
+ color: #C00;
+ }
+
.details {
border: 1px solid #D0D0D0;
border-radius: 4px;
diff --git a/actionpack/test/dispatch/debug_exceptions_test.rb b/actionpack/test/dispatch/debug_exceptions_test.rb
index d17f264582..9878adbfa2 100644
--- a/actionpack/test/dispatch/debug_exceptions_test.rb
+++ b/actionpack/test/dispatch/debug_exceptions_test.rb
@@ -629,7 +629,9 @@ class DebugExceptionsTest < ActionDispatch::IntegrationTest
# Assert correct error
assert_response 500
- assert_select "h2", /error in framework/
+ assert_select "div.exception-message" do
+ assert_select "div", /error in framework/
+ end
# assert source view line is the call to method_that_raises
assert_select "div.source:not(.hidden)" do
@@ -637,7 +639,7 @@ class DebugExceptionsTest < ActionDispatch::IntegrationTest
end
# assert first source view (hidden) that throws the error
- assert_select "div.source:first" do
+ assert_select "div.source" do
assert_select "pre .line.active", /raise StandardError\.new/
end
@@ -680,7 +682,9 @@ class DebugExceptionsTest < ActionDispatch::IntegrationTest
# Assert correct error
assert_response 500
- assert_select "h2", /Third error/
+ assert_select "div.exception-message" do
+ assert_select "div", /Third error/
+ end
# assert source view line shows the last error
assert_select "div.source:not(.hidden)" do
@@ -749,7 +753,9 @@ class DebugExceptionsTest < ActionDispatch::IntegrationTest
get "/nil_annoted_source_code_error", headers: { "action_dispatch.show_exceptions" => true, "action_dispatch.logger" => logger }
assert_select "header h1", /DebugExceptionsTest::Boomer::NilAnnotedSourceCodeError/
- assert_select "#container h2", /nil annoted_source_code/
+ assert_select "#container div.exception-message" do
+ assert_select "div", /nil annoted_source_code/
+ end
end
test "debug exceptions app shows diagnostics for template errors that contain UTF-8 characters" do
diff --git a/railties/test/application/mailer_previews_test.rb b/railties/test/application/mailer_previews_test.rb
index b948f32e56..dfdf790a74 100644
--- a/railties/test/application/mailer_previews_test.rb
+++ b/railties/test/application/mailer_previews_test.rb
@@ -8,6 +8,7 @@ module ApplicationTests
class MailerPreviewsTest < ActiveSupport::TestCase
include ActiveSupport::Testing::Isolation
include Rack::Test::Methods
+ include ERB::Util
def setup
build_app
@@ -299,7 +300,7 @@ module ApplicationTests
app("development")
get "/rails/mailers/notifier"
assert_predicate last_response, :not_found?
- assert_match "Mailer preview 'notifier' not found", last_response.body
+ assert_match "Mailer preview 'notifier' not found", h(last_response.body)
end
test "mailer preview email not found" do
@@ -329,7 +330,7 @@ module ApplicationTests
get "/rails/mailers/notifier/bar"
assert_predicate last_response, :not_found?
- assert_match "Email 'bar' not found in NotifierPreview", last_response.body
+ assert_match "Email 'bar' not found in NotifierPreview", h(last_response.body)
end
test "mailer preview NullMail" do
@@ -385,7 +386,7 @@ module ApplicationTests
get "/rails/mailers/notifier/foo?part=text%2Fhtml"
assert_predicate last_response, :not_found?
- assert_match "Email part 'text/html' not found in NotifierPreview#foo", last_response.body
+ assert_match "Email part 'text/html' not found in NotifierPreview#foo", h(last_response.body)
end
test "message header uses full display names" do