Class: RedCloth::Formatters::Plain::Sanitizer
- Inherits:
-
Object
- Object
- RedCloth::Formatters::Plain::Sanitizer
- Defined in:
- lib/red_cloth_formatters_plain.rb
Class Method Summary collapse
Class Method Details
.strip_tags(text) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/red_cloth_formatters_plain.rb', line 9 def self.(text) # use Rails Sanitizer if available begin text = ActionController::Base.helpers.(text) rescue # otherwise, use custom method inspired from: # RedCloth::Formatters::HTML.clean_html # not very secure, but it's ok as output is still # meant to be escaped if it needs to be shown text.gsub!( /<!\[CDATA\[/, '' ) text.gsub!( /<(\/*)([A-Za-z]\w*)([^>]*?)(\s?\/?)>/ ){|m| block_given? ? yield(m) : ""} end CGI.unescapeHTML(text) end |