Bug #66423 [NEW]: preg_match / preg_replace greedyness changes unpredictably with subject string
| From: | publi at web dot de | Date: | Mon, 06 Jan 2014 02:40:32 +0000 |
| Subject: | Bug #66423 [NEW]: preg_match / preg_replace greedyness changes unpredictably with subject string | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-183604@lists.php.net to get a copy of this message | ||
From: publi at web dot de
Operating system: Debian Linux
PHP version: Irrelevant
Package: *Regular Expressions
Bug Type: Bug
Bug description:preg_match / preg_replace greedyness changes unpredictably with subject string
Description:
------------
I am using a shared debian host where I cannot easily upgrade to a newer
version of PHP myself, currently it is PHP Version 5.3.3-7+squeeze18
I currently experience the expected behavior at roughly 85% of the
inputs:
the preg_* modifiers "sU" make two ".*"s in the search string ungreedy.
Otherwise, at least the 1st occurrence of ".*" is not greedy.
Alterig it to ".*?" fixes the problem.
Behavior reproducibly depended on the subject strings of the search in
my tests.
Since these are lengthy web pages, there is an archive with all source
files at:
http://omegawiki.purodha.net/test-M15/test-M15.tgz
and the test script is also available to run at:
http://omegawiki.purodha.net/test-M15/test-M15.php
and more input files for additional tests ate at:
http://omegawiki.purodha.net/test-M15/
If you want more information or additional tests, feel free to contact
me
via e-mail.
Test script:
---------------
See:
http://omegawiki.purodha.net/test-M15/test-M15.tgz
http://omegawiki.purodha.net/test-M15/test-M15.php
Expected result:
----------------
file regex-1 regex-2
6028 1 1
6245 1 1
Actual result:
--------------
file regex-1 regex-2
6028 1 1
6245 0 1
--
Edit bug report at https://bugs.php.net/bug.php?id=66423&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=66423&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=66423&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=66423&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=66423&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=66423&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=66423&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=66423&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=66423&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=66423&r=support
Expected behavior: https://bugs.php.net/fix.php?id=66423&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=66423&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=66423&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=66423&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=66423&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=66423&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=66423&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=66423&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=66423&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=66423&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=66423&r=mysqlcfg