HTML-escaping of error and info messages

This commit is contained in:
Alexey Verkhovsky 2005-05-09 04:31:02 +00:00
parent 757e58b94f
commit 7be6cbecba
3 changed files with 19 additions and 4 deletions

View file

@ -106,6 +106,21 @@ class ApplicationController < ActionController::Base
end end
end end
def rescue_action_in_public(exception)
render_text <<-EOL
<html>
<body>
<p>There was a controller specific error processing your request.</p>
<!-- \n#{exception}\n#{exception.backtrace.join("\n")}\n -->
</body>
</html>
EOL
end
def local_request?
false
end
def return_to_last_remembered def return_to_last_remembered
# Forget the redirect location # Forget the redirect location
redirect_target, @session[:return_to] = @session[:return_to], nil redirect_target, @session[:return_to] = @session[:return_to], nil

View file

@ -205,9 +205,9 @@ class WikiController < ApplicationController
# the application itself (for application errors, it's better not to rescue the error at all) # the application itself (for application errors, it's better not to rescue the error at all)
rescue => e rescue => e
logger.error e logger.error e
flash[:error] = e.message
if in_a_web? if in_a_web?
redirect_to :web => @web_name, :action => 'edit', redirect_to :web => @web_name, :action => 'edit', :id => @page_name
:action_suffix => "#{@page_name}?msg=#{e.message}"
else else
raise e raise e
end end

View file

@ -61,11 +61,11 @@ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
</h1> </h1>
<% if @error or @flash[:error] %> <div id="error"> <% if @error or @flash[:error] %> <div id="error">
<hr/><p><%= (@error || @flash[:error]) %></p><hr/></div> <hr/><p><%= h(@error || @flash[:error]) %></p><hr/></div>
<% end %> <% end %>
<% if @flash[:info] %> <div id="info"> <% if @flash[:info] %> <div id="info">
<hr/><p><%= @flash[:info].to_s %></p><hr/></div> <hr/><p><%= h @flash[:info] %></p><hr/></div>
<% end %> <% end %>
<%= render 'navigation' unless @web.nil? || @hide_navigation %> <%= render 'navigation' unless @web.nil? || @hide_navigation %>