我想使用RedCloth gem,我安装了它,在我的gem文件中,我把-> gem 'RedCloth‘放在我的show.html.erb中,我把->
<%= RedCloth.new(@post.text).to_html %>我看到了简单的html语法,然后我使用
<%= raw RedCloth.new(@post.text).to_html %>而且它工作得很好,它不安全
某个用户的@post.text -> puts
当我输入<script> alert('!!!') </script>时,我看到“!”处于警戒状态
如何安全使用RedCloth (或推荐其他gem )
发布于 2012-08-28 21:56:29
sanitize gem https://github.com/rgrove/sanitize/是仅将某些html元素列入白名单并阻止其他元素的可靠选择(例如)
https://stackoverflow.com/questions/12159174
复制相似问题