Reputation: 59089
preg_match has limit of str on PHP 5.2.5
<?php
$str1 = 'a@b%c@d' . str_repeat ('=', 33326);
$str2 = 'a@b%c@d' . str_repeat ('=', 33327);
$regexp = '/^(.*)@(.*)%(.*)$/si';
echo preg_match ($regexp, $str1) ? "Correct " : "Wrong "; // works correctly
echo "\n";
echo preg_match ($regexp, $str2) ? "Correct " : "Wrong "; // exhibits the bug
echo "\n";
Upvotes: 7
Views: 7854
Reputation: 53960
preg_last_error() after the second call returns 2 (=PREG_BACKTRACK_LIMIT_ERROR) so you might want to raise this value.
Upvotes: 6