phezco / phez

Phez - the free speech platform
Other
54 stars 15 forks source link

Review input sanitization method for improvements #7

Open phezco opened 9 years ago

phezco commented 9 years ago

I've pushed an update that centralizes the sanitization code into a new model: https://github.com/phezco/phez/blob/master/app/models/sanitizer.rb

I like the idea of sanitizing attributes before they ever hit the database. Now the app assumes data coming from the database has been sanitized of nasty XSS attack vectors, etc. So you'll see things like this in the view:

<%= raw(@comment.body_rendered) %>

One problem is that to support markdown quotes, the markdown processor expects ">" symbols instead of escaped ampersand gt; .

So I'm putting the ">" symbols back in sanitizer.rb. Is this dangerous? Other thoughts?