I know of taking out slashes, changing HTML to ", lowercasing everything. I just don't know what is the best or foolproof way of doing this.
Any help?
I know of taking out slashes, changing HTML to ", lowercasing everything. I just don't know what is the best or foolproof way of doing this.
Any help?
Generally the best option is to use the language's built-in functions for that. For escaping input to MySQL database queries in PHP, use mysql_real_escape_string()
. For escaping output as HTML, use htmlspecialchars()
or htmlentities()
. Ruby on Rails has a function for HTML escaping too: h()
(e.g. <%=h @object.property %>
). Check your language documentation for specifics.
The best filters are inclusive, not exclusive, as you can usually tell what good input should contain.