From 0068d7f46452188f807e413f6cbd32cd765e6530 Mon Sep 17 00:00:00 2001 From: brettp Date: Sat, 30 Jan 2010 22:42:13 +0000 Subject: Refs #1425: Cleaned up regexp for parlse_urls(). git-svn-id: http://code.elgg.org/elgg/trunk@3861 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/lib/input.php | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'engine/lib/input.php') diff --git a/engine/lib/input.php b/engine/lib/input.php index 27204682f..019e4faa0 100644 --- a/engine/lib/input.php +++ b/engine/lib/input.php @@ -111,15 +111,29 @@ function sanitise_filepath($path) { * @return string The output stirng with formatted links **/ function parse_urls($text) { - return preg_replace_callback('/(?"\'\!\(\)]+)/i', + // @todo this causes problems with + // must be ing format (no space). + // By default htmlawed rewrites tags to this format. + // if PHP supported conditional negative lookbehinds we could use this: + // $r = preg_replace_callback('/(?"\'\!\(\),]+)/i', + // + // we can put , in the list of excluded char but need to keep . because of domain names. + // it is removed in the callback. + $r = preg_replace_callback('/(?"\'\!\(\),]+)/i', create_function( '$matches', ' $url = $matches[1]; + if (substr($url, -1, 1) == \'.\') { + $period = \'.\'; + $url = trim($url, \'.\'); + } $urltext = str_replace("/", "/", $url); - return "$urltext"; + return "$urltext$period"; ' ), $text); + + return $r; } /** -- cgit v1.2.3