diff --git a/lib/weblib.php b/lib/weblib.php index 8db61ed3146..80c19443886 100644 --- a/lib/weblib.php +++ b/lib/weblib.php @@ -273,6 +273,13 @@ function text_to_html($text, $smiley=true, $para=true) { $text = eregi_replace("([[:space:]])www.([^[:space:]]*)([[:alnum:]#?/&=])", "\\1www.\\2\\3", $text); + // Remove any whitespace that may be between HTML tags + $text = eregi_replace(">([[:space:]]+)<", "><", $text); + + // Remove any returns that precede or follow HTML tags + $text = eregi_replace("([\n\r])+<", " <", $text); + $text = eregi_replace(">([\n\r])+", "> ", $text); + // Make returns into HTML newlines. $text = nl2br($text);