Skip to content

Instantly share code, notes, and snippets.

@wli
Last active August 29, 2015 14:15
Show Gist options
  • Save wli/8072b88f4382e7f1757d to your computer and use it in GitHub Desktop.
Save wli/8072b88f4382e7f1757d to your computer and use it in GitHub Desktop.
How not to handle HTML escaping in Ruby on Rails.
# Found this in our codebase the other day. Our contractor couldn't figure out how to
# escape html for ouput, so he overrode a Ruby-on-Rails builtin and disabled HTML-injection
# protection for the entire website.
class Object
def html_safe?
true
end
end
class String
def html_safe?
true
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment