A helper to remove extraneous whitespace from text-ified HTML
# File lib/loofah/helpers.rb, line 37 def remove_extraneous_whitespace(string) string.gsub(/\n\s*\n\s*\n/,"\n\n") end
A replacement for Rails's built-in sanitize helper.
Loofah::Helpers.sanitize("<script src=http://ha.ckers.org/xss.js></script>") # => "<script src=\"http://ha.ckers.org/xss.js\"></script>"
# File lib/loofah/helpers.rb, line 18 def sanitize(string_or_io) loofah_fragment = Loofah.fragment(string_or_io) loofah_fragment.scrub!(:strip) loofah_fragment.xpath("./form").each { |form| form.remove } loofah_fragment.to_s end
A replacement for Rails's built-in sanitize_css helper.
Loofah::Helpers.sanitize_css("display:block;background-image:url(http://www.ragingplatypus.com/i/cam-full.jpg)") # => "display: block;"
# File lib/loofah/helpers.rb, line 30 def sanitize_css style_string ::Loofah::HTML5::Scrub.scrub_css style_string end
Generated with the Darkfish Rdoc Generator 2.