From 1f7cbb5a8a7869073d96c0f2dae45be7c0eed0c2 Mon Sep 17 00:00:00 2001 From: Urban Müller Date: Wed, 13 Jul 2016 17:27:45 +0200 Subject: prevent infinite recursions when using ED() in it::replace or ::match --- it_debug.class | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/it_debug.class b/it_debug.class index b0b1598..2c08e4b 100644 --- a/it_debug.class +++ b/it_debug.class @@ -83,7 +83,7 @@ static function dump($args) list($blue, $noblue, $red, $nored, $ansiok) = getenv('IT_ED_BRIGHT') ? array("\033[34m", "\033[m", "\033[33m", "\033[m", 1) : array("\033[34m", "\033[m", "\033[31m", "\033[m", 1); $src = it_debug::srcline(1); - list($function, $paramlist) = it::match('\b(D|ED|EDC|EDX)\s*\((.*)', $src); + list($dummy, $function, $paramlist) = preg_match('#\b(D|ED|EDC|EDX)\s*\((.*)#i', $src, $parts) ? $parts : array(); $paramtokens = token_get_all("?)\s*\n\s*(array|class)#", '$1 $2', $item); # array( and class on same line as key - $item = preg_replace_callback('#array \(\s+([^(){};]{1,100}),\s+\)#', function($m) { return "array (" . it::replace(array("\n\s*" => " "), $m[1]) . ")"; }, $item); # short arrays on 1 line + $item = preg_replace_callback('#array \(\s+([^(){};]{1,100}),\s+\)#', function($m) { return "array (" . preg_replace("#\n\s*#", " ", $m[1]) . ")"; }, $item); # short arrays on 1 line $item = preg_replace('#class (\S+) \{\s+([^({,;]+;)?\s+\}#', 'class $1 { $2 }', $item); # 1-element objects on 1 line #$item = preg_replace('#\{\s*var \$attr#', '{ var $attr', $item); # move $attr on same line $item = preg_replace("#\\(\s*\n\s*\\)#", "()", $item); # empty arrays on 1 line @@ -157,7 +157,7 @@ static function dump($args) if ($htmlok) return "
$r
\n"; else - return $ansiok ? "$r\n" : "\xe2\x96\x88\xe2\x96\x8c" . it::replace(array("\n" => "\n\xe2\x96\x88 "), "$r") . "\n"; + return $ansiok ? "$r\n" : "\xe2\x96\x88\xe2\x96\x8c" . preg_replace("#\n#", "\n\xe2\x96\x88 ", "$r") . "\n"; } /** -- cgit v1.2.3