php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #28690 PCRE Ungreedy glitch
Submitted: 2004-06-08 03:42 UTC Modified: 2004-09-18 01:00 UTC
Votes:2
Avg. Score:4.5 ± 0.5
Reproduced:1 of 2 (50.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: swd120 at psu dot edu Assigned:
Status: No Feedback Package: PCRE related
PHP Version: 5.0.0RC2 OS: Windows XP, Apache 1.3
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2004-06-08 03:42 UTC] swd120 at psu dot edu
Description:
------------
PCRE Ungreedy flag does not work in PHP5 RC2 w32 distribution.  same code on linux distro 4.37 does not duplicate same result.

The flag remains greedy and doesn't replace the first value="ems" is replaces the 2nd one(technically it replaces all of it but i thought it would be easier to explain this way.) See source

Reproduce code:
---------------
	$string='/(name="One".*value="ems")/Usi';
	echo $string."<br>";
	$content = 'One:<select name="One" id="One">
	<option value="">&nbsp;</option>
        <option value="picas">picas</option>
        <option value="ems">ems</option>
        <option value="exs">exs</option>
        <option value="%">%</option>
      	</select>
	Two<select name="Two" id="Two">
        <option value="">&nbsp;</option>
        <option value="picas">picas</option>
        <option value="ems">ems</option>
        <option value="exs">exs</option>
        <option value="%">%</option>
      	</select>';
	$result = preg_match($string, $content);
	$replace ='\1 selected';
	$um = preg_replace($string,$replace,$content);
	echo "matches: ".$result."<br>".$um;

Expected result:
----------------
I expected value="ems" in the "one" select to become value="ems" selected.

Actual result:
--------------
value="ems" in the "two" select became value="ems" selected.



Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-09-18 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Apr 14 20:01:30 2024 UTC