#40846 [NEW]: pcre.backtrack_limit too restrictive

From: Date: Sat, 17 Mar 2007 19:19:57 +0000
Subject: #40846 [NEW]: pcre.backtrack_limit too restrictive
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-110467@lists.php.net to get a copy of this message
From:             crisp at xs4all dot nl
Operating system: all
PHP version:      5.2.1
PHP Bug Type:     PHP options/info functions
Bug description:  pcre.backtrack_limit too restrictive

Description:
------------
The new pcre.backtrack_limit configuration directive is by default too
restrictive (100.000) which results in failure of many - often quite
simple - regular expressions.

I take it that this directive overrules the default setting for
MATCH_LIMIT in PCRE which will also imply that the naming of this
directive is wrong since MATCH_LIMIT is for every match() call in PCRE,
not only those for backtracking.

It would make more sense to change the default of both
pcre.backtrack_limit and pcre.recursion_limit to the ones that PCRE itself
also supplies (10.000.000 for both) - that way there won't be a
compatibility problem with previous versions of PHP as we have now.

Reproduce code:
---------------
$a = 'baab' . str_repeat('a', 100024);
$b = preg_replace('/b.*b/', '', $a);

Expected result:
----------------
I would expect $b to contain 100024 times 'a'

Actual result:
--------------
$b is a nullpointer, preg_last_error() reports '2' which is
PREG_BACKTRACK_LIMIT_ERROR

-- 
Edit bug report at http://bugs.php.net/?id=40846&edit=1
-- 
Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=40846&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=40846&r=trysnapshot52
Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=40846&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=40846&r=fixedcvs
Fixed in release:             http://bugs.php.net/fix.php?id=40846&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=40846&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=40846&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=40846&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=40846&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=40846&r=notwrong
Not enough info:              http://bugs.php.net/fix.php?id=40846&r=notenoughinfo
Submitted twice:              http://bugs.php.net/fix.php?id=40846&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=40846&r=globals
PHP 3 support discontinued:   http://bugs.php.net/fix.php?id=40846&r=php3
Daylight Savings:             http://bugs.php.net/fix.php?id=40846&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=40846&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=40846&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=40846&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=40846&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=40846&r=mysqlcfg


Thread (14 messages)

« previous php.bugs (#110467) next »