Bug #70699 [Opn->Fbk]: Regex limits on repeating patterns

From: Date: Mon, 12 Oct 2015 20:32:45 +0000
Subject: Bug #70699 [Opn->Fbk]: Regex limits on repeating patterns
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-196568@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=70699&edit=1

 ID:                 70699
 Updated by:         requinix@php.net
 Reported by:        bugs dot php dot net at ss dot st dot tc
 Summary:            Regex limits on repeating patterns
-Status:             Open
+Status:             Feedback
 Type:               Bug
 Package:            *Regular Expressions
 Operating System:   OSX and Linux
 PHP Version:        7.0.0RC4
 Block user comment: N
 Private report:     N

 New Comment:

You're probably hitting the backtrack limit in PCRE. Compare the values of the
pcre.backtrack_limit setting on your two setups.


Previous Comments:
------------------------------------------------------------------------
[2015-10-12 19:25:29] bugs dot php dot net at ss dot st dot tc

Description:
------------
Following examples work well in PHP 5, but fail to produce correct results in PHP 7.

Test script:
---------------
<?php

echo preg_match('/((A)+)/', str_repeat('A', 1363)) ? 1 : 0, PHP_EOL;
echo preg_match('/((A)+)/', str_repeat('A', 1364)) ? 1 : 0, PHP_EOL;

echo preg_match('/((A)*)/', str_repeat('A', 1363)) ? 1 : 0, PHP_EOL;
echo preg_match('/((A)*)/', str_repeat('A', 1364)) ? 1 : 0, PHP_EOL;

echo preg_match_all('/((A)+)/', str_repeat('A', 1363)) ? 1 : 0, PHP_EOL;
echo preg_match_all('/((A)+)/', str_repeat('A', 1364)) ? 1 : 0, PHP_EOL;

echo preg_match_all('/((A)*)/', str_repeat('A', 1363)) ? 1 : 0, PHP_EOL;
echo preg_match_all('/((A)*)/', str_repeat('A', 1364)) ? 1 : 0, PHP_EOL;


Expected result:
----------------
Both PHP 5 and 7:
1
1
1
1
1
1
1
1


Actual result:
--------------
PHP 5:
1
1
1
1
1
1
1
1

PHP 7:
1
0
1
0
1
0
1
0



------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=70699&edit=1


Thread (11 messages)

« previous php.bugs (#196568) next »