views:

69

answers:

2

I'm making a fairly basic rails app and I was wondering what's the best way to strip undesirable html from text field (basically, all I'm looking to preserve are links and no more than 2 linebreaks).

Currently, I'm stripping all html and using simpleformat, since it seems to be less overhead than using RDiscount and Markdown/Textile, but this is not really an ideal solution.

+2  A: 

Probably the sanitize helper.

Module ActionView::Helpers::SanitizeHelper

Ben
+1  A: 

Another option is Sanitize gem.

http://wonko.com/post/sanitize

Neeraj Singh
this seems like exactly what i was looking for, thanks.
Optimate
how is this different/better than the Rails built in sanitizer? http://api.rubyonrails.org/classes/HTML/Sanitizer.html
Ben