Re: preg_replace + htmlentities

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<>]+)([\...


Go Back   Usenet Forums > PHP Programming Forums > alt.comp.lang.php

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 07-13-2003
Adam i Agnieszka Gasiorowski FNORD
 
Posts: n/a
Default Re: preg_replace + htmlentities

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/&lt;br"><u>http://phpmailer.sourcefor
> ge.net/&lt;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
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 08:43 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0