Skip to content
Browse files

Sanitize the URLs passed to redirect_to to prevent a potential respon…

…se spli

CGI.rb and mongrel don't do any sanitization of the contents of HTTP headers
  • Loading branch information...
1 parent 4a256d7 commit 9f9a6c4e4c2b431b59dede5d932536316ac57949 @NZKoz NZKoz committed Oct 14, 2008
Showing with 2 additions and 2 deletions.
  1. +2 −2 actionpack/lib/action_controller/response.rb
View
4 actionpack/lib/action_controller/response.rb
@@ -30,9 +30,9 @@ def charset
def redirect(to_url, response_status)
self.headers["Status"] = response_status
- self.headers["Location"] = to_url
+ self.headers["Location"] = to_url.gsub(/[\r\n]/, '')
- self.body = "<html><body>You are being <a href=\"#{to_url}\">redirected</a>.</body></html>"
+ self.body = "<html><body>You are being <a href=\"#{CGI.escapeHTML(to_url)}\">redirected</a>.</body></html>"
end
def prepare!

0 comments on commit 9f9a6c4

Please sign in to comment.
Something went wrong with that request. Please try again.