Skip to content

Instantly share code, notes, and snippets.

@biske
Last active May 13, 2016 14:28
Show Gist options
  • Save biske/fb3e298950e22a758920dc067f01f68f to your computer and use it in GitHub Desktop.
Save biske/fb3e298950e22a758920dc067f01f68f to your computer and use it in GitHub Desktop.

Use html_escape for user input when you don't expect html content. For example first_name shouldn't contain html, and you want to escape special html characters like &, ", <, or >.

Use html_safe for fields that has html, but html which is sanitized previously. For example for article body there should be some <p> tags but not <script> ones. So before saving content to database it should be sanitized.

http://stackoverflow.com/a/29206274/507018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment