php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #1787 Scripting Engine problem
Submitted: 1999-07-21 04:32 UTC Modified: 1999-07-21 05:34 UTC
From: webmaster at softgallery dot com Assigned:
Status: Closed Package: Scripting Engine problem
PHP Version: 4.0 Beta 1 OS: Linux debian 2.1
Private report: No CVE-ID: None
 [1999-07-21 04:32 UTC] webmaster at softgallery dot com
I found two bugs in the new parser.

First str_replace does not behave correctly :

$Content = str_replace("{$Toreplace}",$Val,$Content);
with $Val a string, does not remove the {} (template)

Then ereg_replace :

$Content = ereg_replace("\{$ARemplacer\}",$Val,$Content);
with $Val an int put some garbage characters in the output instead
of the value of $Val

I hope this helps.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [1999-07-21 04:51 UTC] sas at cvs dot php dot net
They work as they do in PHP3. Please provide some test cases (i.e. it should output x, but outputs y)
 [1999-07-21 05:28 UTC] webmaster at softgallery dot com
a simple one for ereg_replace :

echo ereg_replace("\{FOO\}",1,"testtest{FOO}testtest");

does not output testtest1testtest, but testtest.garbagechar.testtest

but echo ereg_replace("\{FOO\}","1","testtest{FOO}testtest");
works normally.

As for str_replace I did not find a test case. This is a quite complex script
and I can't provide it to the mailing list . Here is a bit of the code :

      for ($j=0;$j<count($Templates["ParseVars"][$Name]);$j++)
	{
	  $ToReplace = strtoupper($Templates["ParseVars"][$Name][$j]);
	  $Val = $Vals[strtoupper($ToReplace)];
	  $Content = str_replace("{$ToReplace}",$Val,$Content);
	}

In PHP for example $Content ouputs :
BEFORE
"NOM_CAT" -> "Web Tools"
{CAT_LIEN}{NOM_CAT}

AFTER     {CAT_LIEN}Web Tools

With PHP4 :
BEFORE
"NOM_CAT" ->  "Web Tools"
{CAT_LIEN}{NOM_CAT}

AFTER     {CAT_LIEN}{Web Tools} 

I tried to put some strings directly in the varaibles but the function behaved
normally, so perhaps the problem is more complex.

I can provide the code to a PHP developper directly, but it's not commented
and all variables names are french, so it won't be easy to read. Feel free to ask
anyway.
 [1999-07-21 05:34 UTC] sas at cvs dot php dot net
1. ereg_replace is intended to work like that. Please read the documentation
2. str_replace should work now (CVS version)
 
PHP Copyright © 2001-2017 The PHP Group
All rights reserved.
Last updated: Sun Nov 19 01:31:42 2017 UTC