Rails 3 关于 Sanitize Gem 功能的问题
我是一个相对 Rails 的新手,对消毒宝石有疑问。它很容易安装和使用,但由于某种原因,当我选择拥有自己的元素数组时,它不起作用。它仍在清理我试图批准的元素。这是我的代码:
def scrub(html)
# Setup whitelist of html elements that are allowed.
allowed_elements = ['b', 'blockquote', 'em', 'i', 'li', 'ol', 'p', 'pre', 'u', 'ul']
Sanitize.clean(html, :elements => allowed_elements)
end
但结果显示以下内容:
<p> And Some Content... <script>mal</script>
and <em>italics and bold</em></p>
<ol> <li> list</li> <li> list</li> </ol>
<blockquote> <p> blockquote</p> </blockquote>
<ul> <li> bullet</li> <li> bullet</li> </ul>
感谢您提供有关为什么这种简单格式不起作用的任何指示!
I'm a relative rails newbie and have a question about the sanitize gem. It is easy to install and use, but for some reason when I choose to have my own elements array, it isn't working. It is still sanitizing the elements I'm trying to approve. Here's my code:
def scrub(html)
# Setup whitelist of html elements that are allowed.
allowed_elements = ['b', 'blockquote', 'em', 'i', 'li', 'ol', 'p', 'pre', 'u', 'ul']
Sanitize.clean(html, :elements => allowed_elements)
end
but it is showing the following as a result:
<p> And Some Content... <script>mal</script>
and <em>italics and bold</em></p>
<ol> <li> list</li> <li> list</li> </ol>
<blockquote> <p> blockquote</p> </blockquote>
<ul> <li> bullet</li> <li> bullet</li> </ul>
thanks for any pointers about why this simple format isn't working!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)