Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

content_for fails to sanitize input when using HAML #174

Open
notalex opened this issue Sep 8, 2020 · 0 comments
Open

content_for fails to sanitize input when using HAML #174

notalex opened this issue Sep 8, 2020 · 0 comments

Comments

@notalex
Copy link

notalex commented Sep 8, 2020

See the following pages:

https://content-for-rails.herokuapp.com/works
https://content-for-rails.herokuapp.com/fails

  • The first page is a html.erb while the second is a HAML variant. The source is here. The following is a snippet:
%p HAML: content_for marks input as html_safe but does not sanitize it.
- content_for(:page_title) { "</title><script>alert('Pawned')</script>;" }
- puts content_for(:page_title) #=> prints unsanitized text marked as html_safe.
%p= content_for(:page_title)
  • Debugging reveals that content_for when used in HAML does not sanitize given input.
  • This issue is seen in HAML v1 & v2, Rails 4-6.
  • Not sure whether this should be reported here or on Rails. This issue is only seen when using HAML with rails.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant