阻止 javascript_include_tag 被转义
我正在升级 Rail 3 应用程序,由于某种原因,该行
<%= javascript_include_tag :defaults %>
产生了
<script src="/javascripts/prototype.js?1292866092" type="text/javascript"></script>
<script src="/javascripts/effects.js?1292866092" type="text/javascript"></script>
<script src="/javascripts/dragdrop.js?1292866092" type="text/javascript"></script>
<script src="/javascripts/controls.js?1292866092" type="text/javascript"></script>
<script src="/javascripts/rails.js?1292866092" type="text/javascript"></script>
<script src="/javascripts/application.js?1292608980" type="text/javascript"></script>
在标签前面添加“原始”的效果,但我试图找出它这样做的真正原因。它上面的样式表标签工作正常。我很困惑。有什么帮助吗?
I am upgrading a Rail 3 application and for some reason the line
<%= javascript_include_tag :defaults %>
produces
<script src="/javascripts/prototype.js?1292866092" type="text/javascript"></script>
<script src="/javascripts/effects.js?1292866092" type="text/javascript"></script>
<script src="/javascripts/dragdrop.js?1292866092" type="text/javascript"></script>
<script src="/javascripts/controls.js?1292866092" type="text/javascript"></script>
<script src="/javascripts/rails.js?1292866092" type="text/javascript"></script>
<script src="/javascripts/application.js?1292608980" type="text/javascript"></script>
Adding a 'raw' infront of the tag works but I'm trying to figure out the real reason why it is doing this. The stylesheet tag above it works fine. I'm confused. Any help?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
罪魁祸首是一个覆盖默认 Rails 助手的插件 (semantic_form_builder)。我不认为它有更新,尽管不需要太多就能使其兼容 Rails3。
无论如何,我希望将来能够转向 simple_form。
The culprit was a plugin (semantic_form_builder) that overrides the default rails helpers. I don't think there is an update for it although it shouldn't take much to make it rails3 compatible.
I hope to move to simple_form in the future anyway.
Rails 3 自动转义 html 以进行 Xss 保护,而不是 <%= h .. %>它在 Rails 2.x 中使用。
了解更多信息 http://railscasts.com/episodes/204-xss -保护-in-rails-3
Rails 3 automatically escapes html for Xss protection instead of <%= h .. %> which was used in Rails 2.x.
Learn more about it http://railscasts.com/episodes/204-xss-protection-in-rails-3