public function cleanCommentString($str)
{
$str = strip_tags(trim($str));
if (strlen($str) > self::maxCommentBytes) {
$str = substr($str, 0, self::maxCommentBytes);
}
$str = str_replace(array("\r\n", "\r"), "\n", $str);
if (strpos($str, "\n\n\n") !== false) {
$str = preg_replace('{\\n\\n\\n+}', "\n\n", $str);
}
return $str;
}