Skip to content

Commit 2900dd9

Browse files
author
Petr Kotek
committed
Diff_Renderer_Html_Array: avoid using 'e' modified in preg_replace - use preg_replace_callback instead
1 parent 2545d47 commit 2900dd9

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

Diff for: lib/Diff/Renderer/Html/Array.php

+4-3
Original file line numberDiff line numberDiff line change
@@ -177,19 +177,20 @@ protected function formatLines($lines)
177177
$lines = array_map(array($this, 'ExpandTabs'), $lines);
178178
$lines = array_map(array($this, 'HtmlSafe'), $lines);
179179
foreach($lines as &$line) {
180-
$line = preg_replace('# ( +)|^ #e', "\$this->fixSpaces('\\1')", $line);
180+
$line = preg_replace_callback('# ( +)|^ #', array($this, 'fixSpaces'), $line);
181181
}
182182
return $lines;
183183
}
184184

185185
/**
186186
* Replace a string containing spaces with a HTML representation using  .
187187
*
188-
* @param string $spaces The string of spaces.
188+
* @param string[] $matches Array with preg matches.
189189
* @return string The HTML representation of the string.
190190
*/
191-
function fixSpaces($spaces='')
191+
private function fixSpaces(array $matches)
192192
{
193+
$spaces = $matches[1];
193194
$count = strlen($spaces);
194195
if($count == 0) {
195196
return '';

0 commit comments

Comments
 (0)