diff options
author | Matthew Draper <matthew@trebex.net> | 2018-08-29 14:07:37 +0930 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-08-29 14:07:37 +0930 |
commit | 068fe7dc9045856b822833db5cb7cb690e6000d7 (patch) | |
tree | e9c6ce3a42e29e09bb899b6e4c7e695d97b3c428 /actionview/lib | |
parent | 28e5085070f95f32a6a909cce6d77fd460c73885 (diff) | |
parent | 7c9751d7fe3aec1e67004d1bb5e4a1702fcacafb (diff) | |
download | rails-068fe7dc9045856b822833db5cb7cb690e6000d7.tar.gz rails-068fe7dc9045856b822833db5cb7cb690e6000d7.tar.bz2 rails-068fe7dc9045856b822833db5cb7cb690e6000d7.zip |
Merge pull request #33718 from kddeisz/permit-list
Finish converting whitelist and blacklist references
Diffstat (limited to 'actionview/lib')
-rw-r--r-- | actionview/lib/action_view/helpers/sanitize_helper.rb | 4 | ||||
-rw-r--r-- | actionview/lib/action_view/template/handlers/erb.rb | 14 |
2 files changed, 14 insertions, 4 deletions
diff --git a/actionview/lib/action_view/helpers/sanitize_helper.rb b/actionview/lib/action_view/helpers/sanitize_helper.rb index cb0c99c4cf..f4fa133f55 100644 --- a/actionview/lib/action_view/helpers/sanitize_helper.rb +++ b/actionview/lib/action_view/helpers/sanitize_helper.rb @@ -10,7 +10,7 @@ module ActionView # These helper methods extend Action View making them callable within your template files. module SanitizeHelper extend ActiveSupport::Concern - # Sanitizes HTML input, stripping all tags and attributes that aren't whitelisted. + # Sanitizes HTML input, stripping all but known-safe tags and attributes. # # It also strips href/src attributes with unsafe protocols like # <tt>javascript:</tt>, while also protecting against attempts to use Unicode, @@ -40,7 +40,7 @@ module ActionView # # <%= sanitize @comment.body %> # - # Providing custom whitelisted tags and attributes: + # Providing custom lists of permitted tags and attributes: # # <%= sanitize @comment.body, tags: %w(strong em a), attributes: %w(href) %> # diff --git a/actionview/lib/action_view/template/handlers/erb.rb b/actionview/lib/action_view/template/handlers/erb.rb index b7b749f9da..270be0a380 100644 --- a/actionview/lib/action_view/template/handlers/erb.rb +++ b/actionview/lib/action_view/template/handlers/erb.rb @@ -14,7 +14,17 @@ module ActionView class_attribute :erb_implementation, default: Erubi # Do not escape templates of these mime types. - class_attribute :escape_whitelist, default: ["text/plain"] + class_attribute :escape_ignore_list, default: ["text/plain"] + + [self, singleton_class].each do |base| + base.send(:alias_method, :escape_whitelist, :escape_ignore_list) + base.send(:alias_method, :escape_whitelist=, :escape_ignore_list=) + + base.deprecate( + escape_whitelist: "use #escape_ignore_list instead", + :escape_whitelist= => "use #escape_ignore_list= instead" + ) + end ENCODING_TAG = Regexp.new("\\A(<%#{ENCODING_FLAG}-?%>)[ \\t]*") @@ -47,7 +57,7 @@ module ActionView self.class.erb_implementation.new( erb, - escape: (self.class.escape_whitelist.include? template.type), + escape: (self.class.escape_ignore_list.include? template.type), trim: (self.class.erb_trim_mode == "-") ).src end |