我有一个由Rails3编写的网站.我的帖子模型有一个文本列,命名为"content".在后面板中,html表单使用tinymce将"content"列设置为textarea字段.在首页中,由于使用了tinymce,post.html.erb代码需要用raw方法实现<%= raw @post.content %>.
好的,现在如果我关闭浏览器javascript,这个textarea可以输入没有tinymce,也许用户会输入任何xss之类的<script>alert('xss');</script>.我的前面会显示警报框.
我尝试sanitize(@post.content)在posts_controller中,但sanitize方法将相互过滤tinymce样式.例如,<span style='color:red;'>foo</span>将成为<span>foo</span>.
我的问题是:如何过滤xss输入并同时保留tinymce风格?