|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2002-07-24 03:44 UTC] flash at daaw dot org
Below you see a snippet of a very basic news script that retrieves news items from a file that is build up like this:
<id>:<user>:<date>:<topic>:<bigtext>
below is the script that crashes on eregi_replace, as soon as I comment out the eregi_replace line and change $text1 to $text in the line above, the script works.
--snip--
$n = getdata("$news");
$var1 = 0;
foreach ($n as $a) {
$var1++;
if ($var1 < 10) {
$topic = $a['4'];
$date = $a['3'];
$user = $a['2'];
$text1 = $a['5'];
$text = eregi_replace("&;&", ":", $text1);
echo "<TABLE bgColor=\"#ffffff\" border=0
cellPadding=0 cellSpacing=0 width=\"100%\"><TR><TD>
<TABLE bgColor=\"#cccccc\" border=0 cellPadding=1
cellSpacing=0 width=\"100%\"><TR><TD>
<TABLE bgColor=\"#eeeeee\" border=0 cellPadding=3
cellSpacing=0 width=\"100%\"><TR>
<TD align=center><FONT class=option color=\"#363636\">
<B> $topic.</B></FONT> By $user - $date</TD></TR>
</TABLE></TD></TR></TABLE>$text </TD></TR></TABLE>
<br><center><a href=\"#top\">Back to top</a>
--snip--
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Oct 26 09:00:01 2025 UTC |
Derick: I don't think it's an actual crash :-) He just runs outof memory, not realizing that the meta-character "&" is 'the match' - but the bug is in PHP, as it is resolving the & character in the result of the operation! So it seems a recursion eval in ereg functions. Example: ?php $text="bla&|&bla2"; $a = eregi_replace("&|&", ":", $text); $b = str_replace("&|&", ":", $text); $c = eregi_replace("\\\&|\\\&", ":", $text); echo "$a\n$b\n$c"; ?> Output: $ php -f ./tmp.php bla:|:bla2 bla:bla2 bla&|&bla2strike that please - that's the unescaped pipe ('or') I used.<? $test = "this is a nice text"; $text = eregi_replace("a", "one", "$test"); echo "$text"; ?> -- I noticed also that other eregi functions dont work. like the normal eregi command. could it have something to do with libs I updated on my system ?