Skip to content

Commit caf01e2

Browse files
sebasbitthePanz
authored andcommitted
Fix stack trace code preview in debug screen
1 parent 5bb1131 commit caf01e2

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

lib/exception/sfException.class.php

+4-1
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,10 @@ protected static function fileExcerpt($file, $line)
329329
}
330330

331331
if (is_readable($file)) {
332-
$content = preg_split('#<br />#', preg_replace('/^<code>(.*)<\/code>$/s', '$1', highlight_file($file, true)));
332+
$replaceRegex = '/^(?:<pre><code(?: [^>]+)?>|<code><span(?: [^>]+)?>\s*)(.*?)(?:<\/code><\/pre>|\s*<\/span>\s*<\/code>)$/s';
333+
$splitRegex = '/(\r\n|\n|\r|<br \/>)/';
334+
335+
$content = preg_split($splitRegex, preg_replace($replaceRegex, '$1', highlight_file($file, true)));
333336

334337
$lines = [];
335338
for ($i = max($line - 3, 1), $max = min($line + 3, count($content)); $i <= $max; ++$i) {

0 commit comments

Comments
 (0)