php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #66423 preg_match / preg_replace greedyness changes unpredictably with subject string
Submitted: 2014-01-06 02:40 UTC Modified: 2014-12-30 10:42 UTC
From: publi at web dot de Assigned:
Status: No Feedback Package: *Regular Expressions
PHP Version: Irrelevant OS: Debian Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: publi at web dot de
New email:
PHP Version: OS:

 

 [2014-01-06 02:40 UTC] publi at web dot de
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


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2014-01-06 03:52 UTC] requinix@php.net
-Status: Open +Status: Feedback
 [2014-01-06 03:52 UTC] requinix@php.net
Increase your pcre.backtrack_limit and try again.
 [2014-12-30 10:42 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Apr 20 06:01:28 2024 UTC