aboutsummaryrefslogtreecommitdiffstats
path: root/actionview/lib
diff options
context:
space:
mode:
authorEileen M. Uchitelle <eileencodes@users.noreply.github.com>2019-01-04 09:18:36 -0500
committerGitHub <noreply@github.com>2019-01-04 09:18:36 -0500
commit9f0928322fe0c1209e9cfd97020129797b5e635d (patch)
tree41e0e81bcd6d48b5ea7240011ac4b29acd145e92 /actionview/lib
parentde50002723dfe9324b9dbe4cdfd18c597746f615 (diff)
parenta58db74c4feda7b8e2a02882c030b252d6fa8611 (diff)
downloadrails-9f0928322fe0c1209e9cfd97020129797b5e635d.tar.gz
rails-9f0928322fe0c1209e9cfd97020129797b5e635d.tar.bz2
rails-9f0928322fe0c1209e9cfd97020129797b5e635d.zip
Merge pull request #34797 from gsamokovarov/views-without-defined-protect-against-forgery
Don't expect defined protect_against_forgery? in {token,csrf_meta}_tag
Diffstat (limited to 'actionview/lib')
-rw-r--r--actionview/lib/action_view/helpers/csrf_helper.rb2
-rw-r--r--actionview/lib/action_view/helpers/url_helper.rb2
2 files changed, 2 insertions, 2 deletions
diff --git a/actionview/lib/action_view/helpers/csrf_helper.rb b/actionview/lib/action_view/helpers/csrf_helper.rb
index 69c59844a6..c0422c6ff5 100644
--- a/actionview/lib/action_view/helpers/csrf_helper.rb
+++ b/actionview/lib/action_view/helpers/csrf_helper.rb
@@ -20,7 +20,7 @@ module ActionView
# "X-CSRF-Token" HTTP header. If you are using rails-ujs this happens automatically.
#
def csrf_meta_tags
- if protect_against_forgery?
+ if defined?(protect_against_forgery?) && protect_against_forgery?
[
tag("meta", name: "csrf-param", content: request_forgery_protection_token),
tag("meta", name: "csrf-token", content: form_authenticity_token)
diff --git a/actionview/lib/action_view/helpers/url_helper.rb b/actionview/lib/action_view/helpers/url_helper.rb
index 948dd1551f..d63ada3890 100644
--- a/actionview/lib/action_view/helpers/url_helper.rb
+++ b/actionview/lib/action_view/helpers/url_helper.rb
@@ -618,7 +618,7 @@ module ActionView
end
def token_tag(token = nil, form_options: {})
- if token != false && protect_against_forgery?
+ if token != false && defined?(protect_against_forgery?) && protect_against_forgery?
token ||= form_authenticity_token(form_options: form_options)
tag(:input, type: "hidden", name: request_forgery_protection_token.to_s, value: token)
else