[geeklog-cvs] Geeklog-1.x/public_html lib-common.php,1.720,1.721
Michael Jervis
mjervis at qs1489.pair.com
Tue Aug 12 14:24:56 EDT 2008
Update of /cvsroot/geeklog/Geeklog-1.x/public_html
In directory qs1489.pair.com:/tmp/cvs-serv44491/public_html
Modified Files:
lib-common.php
Log Message:
Fixed make clickable links with quotes (bug #0000691) plus truncated long urls. All credit to Sami for the awesome regular expression ninja attack.
Index: lib-common.php
===================================================================
RCS file: /cvsroot/geeklog/Geeklog-1.x/public_html/lib-common.php,v
retrieving revision 1.720
retrieving revision 1.721
diff -C2 -d -r1.720 -r1.721
*** lib-common.php 12 Aug 2008 09:34:29 -0000 1.720
--- lib-common.php 12 Aug 2008 18:24:53 -0000 1.721
***************
*** 5667,5674 ****
function COM_makeClickableLinks( $text )
{
! $text = preg_replace( '/([^"]?)((((ht|f)tps?):(\/\/)|www\.)[a-z0-9%&_\-\+,;=:@~#\/.\?\[\]]+(\/|[+0-9a-z]))/is', '\\1<a href="\\2">\\2</a>', $text );
! $text = str_replace( '<a href="www', '<a href="http://www', $text );
! return $text;
}
--- 5667,5674 ----
function COM_makeClickableLinks( $text )
{
! $regex = '/((ht|f)tp(s?)\:\/\/|~\/|\/)?([\w]+:\w+@)?(([a-zA-Z]{1}([\w\-]+\.)+([\w]{2,5}))(:[\d]{1,5})?((\/?\w+\/)+|\/?)([\w\-%]+(\.[\w]{3,4})?)?((\?|&|&)[\w\-%]+=[\w\-%]+)*)/is';
! $text = preg_replace( $regex, '<a href="\\1\\5">\\6</a>', $text );
! return $text;
}
***************
*** 5683,5687 ****
function COM_undoClickableLinks( $text )
{
! $text = preg_replace( '/<a href="[^"]*">([^<]*)<\/a>/', '\1', $text );
return $text;
--- 5683,5687 ----
function COM_undoClickableLinks( $text )
{
! $text = preg_replace( '/<a href="([^"]*)">([^<]*)<\/a>/', '\1', $text );
return $text;
More information about the geeklog-cvs
mailing list