php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #33076 str_ireplace not working with 1 character as search
Submitted: 2005-05-20 11:32 UTC Modified: 2005-05-20 16:24 UTC
From: sebastianvasile at yahoo dot com Assigned:
Status: Closed Package: Strings related
PHP Version: 5.0.4 OS: Linux 2.6.3
Private report: No CVE-ID:
 [2005-05-20 11:32 UTC] 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

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-05-20 11:35 UTC] 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 15:52 UTC] 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 16:16 UTC] sebastianvasile at yahoo dot com
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.
 [2005-05-20 16:24 UTC] tony2001@php.net
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2014 The PHP Group
All rights reserved.
Last updated: Thu Apr 17 16:02:22 2014 UTC