A helper to remove extraneous whitespace from text-ified HTML
# File lib/loofah/helpers.rb, line 25 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.scrub_fragment(string_or_io, :strip).to_s end