aboutsummaryrefslogtreecommitdiffstats
path: root/actionview
diff options
context:
space:
mode:
authorTimm <kaspth@gmail.com>2013-08-09 22:10:28 +0200
committerTimm <kaspth@gmail.com>2014-06-16 21:04:03 +0200
commitd1de087467b1d3a0bc08f6d372db33bf2dcc80d6 (patch)
tree15cc331b0d0ae1574291263c9a8e01354a118705 /actionview
parent945e7f529e1c9cb2690a2bbe3374f883771a2cd1 (diff)
downloadrails-d1de087467b1d3a0bc08f6d372db33bf2dcc80d6.tar.gz
rails-d1de087467b1d3a0bc08f6d372db33bf2dcc80d6.tar.bz2
rails-d1de087467b1d3a0bc08f6d372db33bf2dcc80d6.zip
Extracted the common xpaths to remove into XPATHS_TO_REMOVE.
Diffstat (limited to 'actionview')
-rw-r--r--actionview/lib/action_view/helpers/sanitize_helper/sanitizers.rb6
1 files changed, 4 insertions, 2 deletions
diff --git a/actionview/lib/action_view/helpers/sanitize_helper/sanitizers.rb b/actionview/lib/action_view/helpers/sanitize_helper/sanitizers.rb
index 0e2e1826ec..3f2cdd53e6 100644
--- a/actionview/lib/action_view/helpers/sanitize_helper/sanitizers.rb
+++ b/actionview/lib/action_view/helpers/sanitize_helper/sanitizers.rb
@@ -3,6 +3,8 @@ require 'active_support/deprecation'
require 'action_view/helpers/sanitize_helper/permit_scrubber'
module ActionView
+ XPATHS_TO_REMOVE = %w{.//script .//form comment()}
+
class Sanitizer
# :nodoc:
def sanitize(html, options = {})
@@ -25,7 +27,7 @@ module ActionView
return html if html.empty?
fragment = Loofah.fragment(html)
- remove_xpaths(fragment, %w{.//script .//form comment()})
+ remove_xpaths(fragment, XPATHS_TO_REMOVE)
fragment.text
end
end
@@ -66,7 +68,7 @@ module ActionView
@permit_scrubber.attributes = options[:attributes]
loofah_fragment.scrub!(@permit_scrubber)
else
- remove_xpaths(loofah_fragment, %w{.//script .//form comment()})
+ remove_xpaths(loofah_fragment, XPATHS_TO_REMOVE)
loofah_fragment.scrub!(:strip)
end
loofah_fragment.to_s