From 5ccf183b325e899685e4ac6ded56e3c1dd7a26c9 Mon Sep 17 00:00:00 2001 From: deva Date: Tue, 28 Oct 2008 12:34:44 +0000 Subject: Fixed annoying bug on url/image parsing. --- forum/utils/parser.php | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'forum/utils/parser.php') diff --git a/forum/utils/parser.php b/forum/utils/parser.php index f79be2a..e4a164e 100644 --- a/forum/utils/parser.php +++ b/forum/utils/parser.php @@ -10,6 +10,8 @@ include_once($UTIL_DIR . "/smileys.php"); // error_reporting // +// http://www1.cs.columbia.edu/~lennox/perlre.html + function parse($input, $indent = "") { global $testing; @@ -39,20 +41,20 @@ function parse($input, $indent = "") while(strpos($output, $imgendmarker)) $imgendmarker .= $imgendsymbol; // Find and mark image URLs (so that they don't get converted into normal links) - $output = preg_replace("/http:\/\/(.*?\.jpg|.*?\.gif|.*?\.png|.*?\.jpeg)/", $imgstartmarker."$1".$imgendmarker, $output); + $output = preg_replace("/http:\/\/(\S*?\.jpg|\S*?\.gif|\S*?\.png|\S*?\.jpeg)/", $imgstartmarker."$1".$imgendmarker, $output); - // Replace URLs with tags - $output = preg_replace("/http:\/\/(.*?)([\n ]|$)/s", "$1$2", $output); + // Replace URLs with tags + $output = preg_replace("/http:\/\/(\S*?)([\n ]|$)/s", "$1$2", $output); // Convert marked images to img tags and links - $output = preg_replace("/".$imgstartmarker."(.*?)".$imgendmarker."/s", "\"$1\"", $output); + $output = preg_replace("/".$imgstartmarker."(\S*?)".$imgendmarker."/s", "\"$1\"", $output); - // Replace URLs with tags + // Replace file links with their thumbnails. $output = preg_replace("/\{\{([0-9]*?)\}\}/s", "", $output); - // Replace [quote title=...]...[/quote] + // Replace [quote title=...]...[/quote] $urls = ""; - while(($start = strpos($output, "[quote"))) { + while(($start = strpos($output, "[quote"))) { $pre = substr($output, 0, $start); $url = substr($output, $start); $end = strpos($url, "[/quote]") + strlen("[/quote]"); -- cgit v1.2.3