From: <lei...@us...> - 2008-05-29 08:27:18
|
Author: leithoff Date: Thu May 29 09:53:46 2008 New Revision: 25532 URL: http://www.egroupware.org/viewvc?rev=3D25532&view=3Drev Log: bugfix regarding the replace of tags, sometimes you get endless loops, sinc= e there seems to be a start and endtag, but the substitution does not take = place. handeled that by checking if the starttag is still at the same posit= ion, and checking the length of the sourcestring Modified: trunk/felamimail/inc/class.bofelamimail.inc.php Modified: trunk/felamimail/inc/class.bofelamimail.inc.php URL: http://www.egroupware.org/viewvc/trunk/felamimail/inc/class.bofelamima= il.inc.php?rev=3D25532&r1=3D25531&r2=3D25532&view=3Ddiff =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- trunk/felamimail/inc/class.bofelamimail.inc.php (original) +++ trunk/felamimail/inc/class.bofelamimail.inc.php Thu May 29 09:53:46 2008 @@ -32,7 +32,7 @@ ); = var $mbox; // the mailbox identifier any function should use - + static $debug =3D false; //true; // sometimes debuging is quite handy, t= o see things. check with the error log to see results // define some constants // message types var $type =3D array("text", "multipart", "message", "application", "audi= o", "image", "video", "other"); @@ -752,17 +752,25 @@ if ($_body) { $begin_tag =3D strpos(strtolower($_body),'<'.$tag); while ($begin_tag !=3D=3D FALSE) { + $bodylength =3D strlen($_body); //since there is a begin tag there should be an end tag, starting som= ewhere at least the length of the tag down chars further down $end_tag=3Dstrpos(strtolower($_body),$endtag.'>',$begin_tag+$taglen+1= ); if ($end_tag !=3D=3D FALSE && $end_tag > $begin_tag) { + if (self::$debug) error_log("bofelamimail:replaceTagsCompletley: sub= stitution of (<)$tag to $endtag(>) from position $begin_tag:". substr($_bod= y,$begin_tag,$taglen+10)); + if (self::$debug) error_log("bofelamimail:replaceTagsCompletley: sub= stitute to $endtag(>) at position ".($end_tag+$endtaglen+1).":".substr($_bo= dy,$end_tag+$endtaglen+1-$endtaglen-1,$endtaglen+10)); $_body =3D substr($_body,0,$begin_tag-1).substr($_body,$end_tag+$end= taglen+1); } else { //somehow there is a begin tag of a tag but no end tag. throw it away // we will take care of this later on/somewhere else break; } - $begin_tag =3D strpos(strtolower($_body),'<'."$tag"); - + $new_start =3D strpos(strtolower($_body),'<'."$tag"); + if ($new_start =3D=3D $begin_tag && $bodylength =3D=3D strlen($_body)= ) { + // sometimes the substitution does not take place, so if the positio= n does not change: break + break; + } else { + $begin_tag =3D $new_start; + } if (strlen($_body)<$begin_tag) break; } } |