From 21aae88fc189bc2672ef563f6ed7ae42a3b8634e Mon Sep 17 00:00:00 2001 From: Christian Schneider Date: Thu, 20 Aug 2009 14:42:19 +0000 Subject: Warn when we hit pcre.backtracking_limit --- it.class | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'it.class') diff --git a/it.class b/it.class index 9d43983..440d889 100644 --- a/it.class +++ b/it.class @@ -352,7 +352,17 @@ function match($pattern, $string, $p = array()) setlocale(LC_CTYPE, $oldlocale); if (!$r) # no match + { + static $backtrackerror; + + if (!isset($backtrackerror)) + $backtrackerror = defined('PREG_BACKTRACK_LIMIT_ERROR') ? constant('PREG_BACKTRACK_LIMIT_ERROR') : 0; + + if ($backtrackerror && preg_last_error() == $backtrackerror) # Silence phpversionlint.php commit hook: function_exists('preg_last_error') + it::error("Exceeded pcre.backtrack_limit of " . ini_get('pcre.backtrack_limit') . " bytes"); + $result = $p['all'] ? array() : null; + } else if (count($m) == 1) # no capture $result = $m[0]; else if (count($m) == 2) # one capture -- cgit v1.2.3