Loofah is an HTML sanitizer. It will always fix broken markup, but can also sanitize unsafe tags in a few different ways, and transform the markup for storage or display. It's built on top of Nokogiri and libxml2, so it's fast. And it uses html5lib's whitelist, so it most likely won't make your codes less secure. \* \* These statements have not been evaluated by Netexperts.
Gemfile gem 'loofah', '~> 0.3.1'
install gem install loofah -v 0.3.1