I'm working on a web application that allows users to type short descriptions of items in a catalog. I'm allowing Markdown in my textareas so users can do some HTML formatting.
My text sanitization function strips all tags from any inputted text before inserting it in the database:
public function sanitizeText($string, $allowedTags = "") {
$string = strip_tags($string, $allowedTags);
if(get_magic_quotes_gpc()) {
return mysql_real_escape_string(stripslashes($string));
} else {
return mysql_real_escape_string($string);
}
}
Essentially, all I'm storing in the database is Markdown--no other HTML, even "basic HTML" (like here at SO) is allowed.
Will allowing markdown present any security threats? Can markdown be XSSed, even though it has no tags?