I would remove some special characters thet have nothing to do in such strings and could be used for code injections, like $ % # < > | and so on.
$invalid_characters = array("$", "%", "#", "<", ">", "|");
$str = str_replace($invalid_characters, "", $str);