#45488 [NEW]: str_replace failed when the $subject parameter length exceeds 100009

From: Date: Fri, 11 Jul 2008 17:57:39 +0000
Subject: #45488 [NEW]: str_replace failed when the $subject parameter length exceeds 100009
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-126507@lists.php.net to get a copy of this message
From:             webez dot cn at gmail dot com
Operating system: Windows 2003
PHP version:      5.2.6
PHP Bug Type:     Regexps related
Bug description:  str_replace failed when the $subject parameter length exceeds 100009

Description:
------------
if the $subject parameter's length exceeds 100009, str_replace has no
return value.

This has been reproduced on windows 2003 with php 5.2.6 and Linux with php
5.2.5

PS:
If there is backslash in the $subject parameter and $pattern parameter,
the critical poiont will change, the maximum string length to reproduce
this bug will increase.

Reproduce code:
---------------
<?
$dummyText=str_pad("[start]",100016-strlen("[start][end]"),"*")."[end]";
str_replace_test($dummyText);
$dummyText=str_pad("[start]",100017-strlen("[start][end]"),"*")."[end]";
str_replace_test($dummyText);
function str_replace_test($dummyText){
	$result=preg_replace("/\[start\](.+?)\[end\]/eis","passed",$dummyText);
	$result==""?$result="failed":true;
	echo "str_replace with length: ".strlen($dummyText)."
".$result."<br>";
}
?>

Expected result:
----------------
str_replace with length: 100009 passed
str_replace with length: 100010 passed

Actual result:
--------------
str_replace with length: 100009 passed
str_replace with length: 100010 failed

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



Thread (3 messages)

« previous php.bugs (#126507) next »