summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--it.class10
1 files changed, 10 insertions, 0 deletions
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