pebblecode / vistazo

A light weight application to keep track of who's working on what, when.
1 stars 0 forks source link

Sanitize output from malicious user input #215

Closed taktran closed 12 years ago

taktran commented 12 years ago

Clean the output from the server, if there has been malicious user input.

One problem found:

List of things to sanitize:

In tests with

within_fieldset("Team name") do
  fill_in 'team_name', :with => "Ha! <script type='text/javascript'>alert('hello!');</script>"
  click_button 'update'
end

<%= @team.name %> returns "Ha! alert('hello!');" <%= h @team.name %> returns "Ha! <script type='text/javascript'>alert('hello!');</script>"

In the latter, if you open it in the debugger, and print out page.body, you get Ha! &lt;script type='text/javascript'&gt;alert('hello!');&lt;/script&gt;

Hence I test with

within("#team-name h2") do
  page.should have_content("Ha! <script type='text/javascript'>alert('hello!');</script>")
end

Resources

taktran commented 12 years ago

Done on staging