Rails3 sanitize escape HTML rather than remove
Is there a way to have the ActionView::Helpers::SanitizeHelper#sanitize method escape the offending HTML rather 开发者_开发问答than just completely removing it?
I would use h
but I need the sanitize method because you can set it to ignore certain tags.
The built-in sanitize method is merely a shortcut utility, and doesn't even handle malformed markup.
Please do yourself a favor and check out http://github.com/rgrove/sanitize
You can build filters for specific tags and is highly-customizable.
You can also use ruby's CGI::escapeHTML method
self.content = CGI::escapeHTML(self.content)
精彩评论