From d46428b5b765f921b4cb633808f22ef303516c62 Mon Sep 17 00:00:00 2001 From: Michael Walker Date: Sun, 3 Jan 2016 21:05:31 +0000 Subject: [PATCH] Trim leading newlines and trailing whitespace from code blocks. --- inc/functions.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/inc/functions.php b/inc/functions.php index cd1f8fde..ff5d51df 100755 --- a/inc/functions.php +++ b/inc/functions.php @@ -2085,6 +2085,8 @@ function markup(&$body, $track_cites = false) { $code = isset($val[2]) ? $val[2] : $val[1]; $code_lang = isset($val[2]) ? $val[1] : ""; + $code = rtrim(ltrim($code, "\r\n")); + $code = "
".str_replace(array("\n","\t"), array("
","	"), htmlspecialchars($code))."
"; $body = str_replace("", $code, $body);