Skip to content

Commit 7282ed8

Browse files
committed
Sanitize the URLs passed to redirect_to to prevent a potential response spli
CGI.rb and mongrel don't do any sanitization of the contents of HTTP headers
1 parent e857799 commit 7282ed8

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

actionpack/lib/action_controller/response.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ def charset
3030

3131
def redirect(to_url, response_status)
3232
self.headers["Status"] = response_status
33-
self.headers["Location"] = to_url
33+
self.headers["Location"] = to_url.gsub(/[\r\n]/, '')
3434

35-
self.body = "<html><body>You are being <a href=\"#{to_url}\">redirected</a>.</body></html>"
35+
self.body = "<html><body>You are being <a href=\"#{CGI.escapeHTML(to_url)}\">redirected</a>.</body></html>"
3636
end
3737

3838
def prepare!

0 commit comments

Comments
 (0)