This is a discussion on Re: preg_replace + htmlentities within the alt.comp.lang.php forums, part of the PHP Programming Forums category; Sandy Lewanscheck wrote: > function replace_uri($str) > { > $pattern = > '#(^|[^\"=]{1})(http://|ftp://|mailto:|news:)([^\s<>]+)([\...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
Sandy Lewanscheck wrote:
> function replace_uri($str) > { > $pattern = > '#(^|[^\"=]{1})(http://|ftp://|mailto:|news:)([^\s<>]+)([\s\n<>]|$)#sm'; > return preg_replace($pattern,"\\1<a > href=\"\\2\\3\"><u>\\2\\3</u></a>\\4",$str); > } > $message=htmlentities($message); > $message=replace_uri($message); > > will result in > > <a > href="http://phpmailer.sourceforge.net/<br"><u>http://phpmailer.sourcefor > ge.net/<br</u></a> > > and > > $message=replace_uri($message); > $message=htmlentities($message); > won't work either. > So i would need a function doing both at the same time. > Any ideas? Replace the "dangerous" chars with "something else" in the replace_url function (like '[:lt:]'), then apply replace_url, htmlentities, then replace the custom string back into the 'correct' character (using str_replace, for example). -- Seks, seksić, seksolatki... news:pl.soc.seks.moderowana http://hyperreal.info / ALinkA / bOrk! * WiNoNa ) ( http://szatanowskie-ladacznice.0-700.pl foReVeR( * ) Poznaj jej zwiewne kształty... http://www.opera.com 007 |
![]() |
| Thread Tools | |
| Display Modes | |
|
|