#33076 [Opn]: str_ireplace not working with 1 character as search
| From: | sebastianvasile at yahoo dot com | Date: | Fri, 20 May 2005 14:16:29 +0000 |
| Subject: | #33076 [Opn]: str_ireplace not working with 1 character as search | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-79258@lists.php.net to get a copy of this message | ||
ID: 33076
User updated by: sebastianvasile at yahoo dot com
Reported By: sebastianvasile at yahoo dot com
Status: Open
Bug Type: Strings related
Operating System: Linux 2.6.3
PHP Version: 5.0.4
New Comment:
I think I found what crashes it:
I have:
str_ireplace("t", "ttttt", "This is a text");
I get: crash.
************************************************
I have:
str_ireplace("t", "tttt", "This is a text");
I get: tttthis is a ttttext (final t not replaced)
***********************************************
I have:
str_ireplace("Z", "zzzzzz", "zThis is a text");
I get: zzzzzzThis is a
One more "z" in replacement will crash.
*********************************************
Seems like the original string size is not increased.
Previous Comments:
------------------------------------------------------------------------
[2005-05-20 15:52:16] sebastianvasile at yahoo dot com
I tested this build:
May 20 2005 10:18:50 on my WinMe machine.
I cannot make a linux test (like the original report) because I cannot
administrate the server.
It's not working on my machine, it gives an error in Kernel32.dll
error.
I found a strange behaviour:
If I have:
"this is a text" and try to replace the "t"'s with something else than
it works fine. (but str_replace could be used instead)
If I have:
"This is a text" (at least one "t" in uppercase) it crashes.
It works fine for 2 characters.
I hope I'm doing this report right as I don't want to cause more
trouble than to help.
------------------------------------------------------------------------
[2005-05-20 11:35:10] sniper@php.net
Please try using this CVS snapshot:
http://snaps.php.net/php5-latest.tar.gz
For Windows:
http://snaps.php.net/win32/php5-win32-latest.zip
I can not reproduce this.
------------------------------------------------------------------------
[2005-05-20 11:32:57] sebastianvasile at yahoo dot com
Description:
------------
str_ireplace is causing a "Page cannot be displayed" when I pass a
single letter as $search.
Reproduce code:
---------------
$value = str_ireplace($keyword, "<font
color=\"red\">".strtoupper($keyword)."</font>", $value);
I want to use this code for highlighting $keyword found in $value.
$value is a large string.
It works fine if $keyword has more than one caracter.
It works fine if I use str_replace.
If I pass only one character I get a Page cannot be displayed
Expected result:
----------------
String with characters replaced.
Actual result:
--------------
The page cannot be displayed, in IE 6.0.2800.1106, on Win Me
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=33076&edit=1