Bug #51663 [Bgs]: PHP preg_match doesn't match string which should match
| From: | jordi dot salvat dot i dot alabart at gmail dot com | Date: | Tue, 04 May 2010 18:36:51 +0000 |
| Subject: | Bug #51663 [Bgs]: PHP preg_match doesn't match string which should match | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-150181@lists.php.net to get a copy of this message | ||
Edit report at http://bugs.php.net/bug.php?id=51663&edit=1
ID: 51663
User updated by: jordi dot salvat dot i dot alabart at gmail dot com
Reported by: jordi dot salvat dot i dot alabart at gmail dot com
Summary: PHP preg_match doesn't match string which should match
Status: Bogus
Type: Bug
Package: PCRE related
Operating System: Ubuntu
PHP Version: 5.3.2
New Comment:
Thanks a lot for diagnosing this one.
Clearly I should avoid excessive backtracking by using the likes of
/([^:]+)+:/ instead of /(.+)+/.
I've filed a report for the incorrect return value in
http://bugs.php.net/bug.php?id=51741
Previous Comments:
------------------------------------------------------------------------
[2010-04-30 00:03:36] felipe@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
Change the pcre.backtrack_limit directive value. [1]
Tested on 5.3SVN:
<?php
printf("pcre.backtrack_limit = %d\n", ini_get('pcre.backtrack_limit'));
var_dump(preg_match("/(.+)+:/", "a:bbbbbbbbbbbbb")); // 0
var_dump(preg_last_error()); // 2 (i.e. PREG_BACKTRACK_LIMIT_ERROR)
ini_set('pcre.backtrack_limit', 1000000);
printf("pcre.backtrack_limit = %d\n", ini_get('pcre.backtrack_limit'));
var_dump(preg_match("/(.+)+:/", "a:bbbbbbbbbbbbb")); // 1
var_dump(preg_last_error()); // 0
[1] http://docs.php.net/manual/en/pcre.configuration.php
------------------------------------------------------------------------
[2010-04-28 17:48:13] jordi dot salvat dot i dot alabart at gmail dot
com
No, I didn't try it myself. A colleague (Diego Campoy) with more time
available downloaded, compiled, and tested my first steps-to-reproduce
in 5.3.2, thus confirming the bug.
Diego confirms that he tested with the bundled PCRE library, version
7.8.
------------------------------------------------------------------------
[2010-04-28 11:45:56] pajoye@php.net
Only to be sure:
did you actually try using 5.3.2 and the bundled PCRE? You can test it
without having to install PHP on your system. You only have to compile
php. The same applies for php 5.2.13.
------------------------------------------------------------------------
[2010-04-28 11:31:07] adconrad at ubuntu dot com
Given that Ubuntu builds PHP against the system libpcre, and pcretest
(by definition, but also a quick visual check with ldd) also uses the
system libpcre, it seems unlikely this is a problem with libpcre itself,
since pcretest works and PHP doesn't.
------------------------------------------------------------------------
[2010-04-26 12:18:53] johannes@php.net
Are you using the bundled PCRE lib or your system's one? - Default is
the bundled one. currently bundled is 8.02. i assume this is a PCRE
and no PHP issue.
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
http://bugs.php.net/bug.php?id=51663
--
Edit this bug report at http://bugs.php.net/bug.php?id=51663&edit=1