Skip to content

Commit

Permalink
HTML-escape csrf meta contents
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremy committed Feb 5, 2010
1 parent 2191aa4 commit 3062bc7
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion actionpack/lib/action_view/helpers/csrf_helper.rb
Expand Up @@ -4,7 +4,7 @@ module CsrfHelper
# Returns a meta tag with the request forgery protection token for forms to use. Put this in your head.
def csrf_meta_tag
if protect_against_forgery?
%(<meta name="csrf-param" content="#{Rack::Utils.escape(request_forgery_protection_token)}"/>\n<meta name="csrf-token" content="#{Rack::Utils.escape(form_authenticity_token)}"/>).html_safe
%(<meta name="csrf-param" content="#{Rack::Utils.escape_html(request_forgery_protection_token)}"/>\n<meta name="csrf-token" content="#{Rack::Utils.escape_html(form_authenticity_token)}"/>).html_safe
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions actionpack/test/controller/request_forgery_protection_test.rb
Expand Up @@ -210,7 +210,7 @@ def setup
@request = ActionController::TestRequest.new
@request.format = :html
@response = ActionController::TestResponse.new
@token = "cf50faa3fe97702ca1ae"
@token = "cf50faa3fe97702ca1a/=?"

ActiveSupport::SecureRandom.stubs(:base64).returns(@token)
ActionController::Base.request_forgery_protection_token = :authenticity_token
Expand All @@ -227,7 +227,7 @@ def setup
@controller = FreeCookieController.new
@request = ActionController::TestRequest.new
@response = ActionController::TestResponse.new
@token = "cf50faa3fe97702ca1ae"
@token = "cf50faa3fe97702ca1a/=?"

ActiveSupport::SecureRandom.stubs(:base64).returns(@token)
end
Expand Down

0 comments on commit 3062bc7

Please sign in to comment.