From ef5607dcad6a1d0aa3a19b06381258e174e671b6 Mon Sep 17 00:00:00 2001 From: sebasbit Date: Mon, 12 Aug 2024 23:35:12 -0500 Subject: [PATCH] Fix stack trace code preview in debug screen --- lib/exception/sfException.class.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/exception/sfException.class.php b/lib/exception/sfException.class.php index 19fd9d950..31dfcfa2c 100644 --- a/lib/exception/sfException.class.php +++ b/lib/exception/sfException.class.php @@ -329,7 +329,10 @@ protected static function fileExcerpt($file, $line) } if (is_readable($file)) { - $content = preg_split('#
#', preg_replace('/^(.*)<\/code>$/s', '$1', highlight_file($file, true))); + $replaceRegex = '/^(?:
]+)?>|]+)?>\s*)(.*?)(?:<\/code><\/pre>|\s*<\/span>\s*<\/code>)$/s';
+            $splitRegex = '/(\r\n|\n|\r|
)/'; + + $content = preg_split($splitRegex, preg_replace($replaceRegex, '$1', highlight_file($file, true))); $lines = []; for ($i = max($line - 3, 1), $max = min($line + 3, count($content)); $i <= $max; ++$i) {