php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #41483 str_ireplace causes script to be treated like download
Submitted: 2007-05-24 08:54 UTC Modified: 2007-05-24 09:25 UTC
From: phpbug at p-s dot co dot nz Assigned:
Status: Not a bug Package: *General Issues
PHP Version: 5.2.1 OS: Linux
Private report: No CVE-ID: None
 [2007-05-24 08:54 UTC] phpbug at p-s dot co dot nz
Description:
------------
str_ireplace() causes errors with some particular inputs.  If you save the following line into test.php:
<?php echo str_ireplace("\r", '', 'interclub_test@p-s.co.nz'); ?>

and try to load it in a browser, the browser will ask what to do with the php file instead of running it as normal.  E.g. "Opening test.php.  You have chosen to open test.php which is a: PHP Coder File from: http://www.psal.co.nz.  What should Firefox do with this file? etc".

A demo is at www.psal.co.nz/test.php. The case sensitive version str_replace() does not have the same problem, and str_ireplace() often works depending what is thrown at it.

Actually the PHP version is 5.2.1 but I can't upgrade to the latest for testing because I am using shared hosting and they use 5.2.1. I apologise if the bug has vanished in a more recent version but this is pretty easy to test.

Reproduce code:
---------------
<?php echo str_ireplace("\r", '', 'interclub_test@p-s.co.nz'); ?>

Expected result:
----------------
interclub_test@p-s.co.nz

Actual result:
--------------
The browser will ask what to do with the php file.  E.g. "Opening test.php.  You have chosen to open test.php which is a: PHP Coder File from: http://www.psal.co.nz.  What should Firefox do with this file?" etc.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-05-24 09:23 UTC] judas dot iscariote at gail dot com
This issue is already reported and fixed in PHP 5.2.2 , do not report stuff more than once.
 [2007-05-24 09:25 UTC] scottmac@php.net
It's already fixed in 5.2.2.
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Tue Oct 06 21:00:01 2026 UTC