开发者

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)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜