aboutsummaryrefslogtreecommitdiffstats
path: root/app/controllers/application_controller.rb
diff options
context:
space:
mode:
authorGareth Rees <gareth@mysociety.org>2014-04-02 09:27:43 +0100
committerGareth Rees <gareth@mysociety.org>2014-04-02 09:27:43 +0100
commitb16bd59bc5a58cebe3f9fbf3d031f813bb720cff (patch)
tree5c0248c64ae180650b79433038911909b1d358a7 /app/controllers/application_controller.rb
parentbdb7ae6b556176f21cf58a7b897e74cdbf409352 (diff)
parentee2d0f30b7699248c2ace02c12ce7223102b6077 (diff)
Merge branch 'issues/1406-render-exception-error' into rails-3-develop
Diffstat (limited to 'app/controllers/application_controller.rb')
-rw-r--r--app/controllers/application_controller.rb10
1 files changed, 10 insertions, 0 deletions
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index 370e8e15c..410778d9a 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -131,6 +131,7 @@ class ApplicationController < ActionController::Base
case exception
when ActiveRecord::RecordNotFound, RouteNotFound
@status = 404
+ sanitize_path(params)
when PermissionDenied
@status = 403
else
@@ -441,6 +442,15 @@ class ApplicationController < ActionController::Base
`git log -1 --format="%H"`.strip
end
+ # URL Encode the path parameter for use in render_exception
+ #
+ # params - the params Hash
+ #
+ # Returns a Hash
+ def sanitize_path(params)
+ params.merge!(:path => Rack::Utils.escape(params[:path])) if params.key?(:path)
+ end
+
# URL generating functions are needed by all controllers (for redirects),
# views (for links) and mailers (for use in emails), so include them into
# all of all.