AnA*_*ice 10 gem ruby-on-rails sanitize ruby-on-rails-3
现在我们正在使用sanitize gem:https://github.com/rgrove/sanitize
问题是如果你输入" hello & world"sanitize将数据保存在DB中:
hello & world
Run Code Online (Sandbox Code Playgroud)
你怎么能将白名单列入白名单&.我们希望清理删除所有可能的恶意html和JS /脚本标记.但是我们可以使用&符号.
想法?谢谢
Sanitize 始终会将输出内容转换为有效 html/xhtml 的 html 实体。
我可以确定的最好方法是过滤输出
Sanitize.fragment("hello & world").gsub('&','&') #=> "Hello & world"
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4596 次 |
| 最近记录: |