Rails 4 redirects to 'data:,' in Chrome

后端 未结 3 505
予麋鹿
予麋鹿 2020-12-31 04:03

There is a weird behavior in Google Chrome, which is also described in this question: rails redirects to 'data:,'

When a new resource is being created and my

3条回答
  •  时光取名叫无心
    2020-12-31 04:35

    Ok I think I know what this is. You can specify images and text inside a data: protocol, and I believe Chrome is seeing escaped HTML and thinking it is data. Since the mime type is not specified, it leaves the mime type blank after the colon, and just prints the comma.

    http://guides.rubyonrails.org/security.html#redirection

    Rails 4 automatically escapes HTML, so if you are trying to render HTML, you have to indicate not to escape it. Look at the options for render:

    http://guides.rubyonrails.org/security.html#redirection

    You can use raw() to render direct HTML.

    http://www.webbydude.com/posts/9-the-h-helper-in-rails-3

提交回复
热议问题