From 6d45ca83efc0f28bb00ecab1a9b4964279cc26b5 Mon Sep 17 00:00:00 2001 From: nikrou Date: Mon, 9 Jan 2006 20:30:21 +0000 Subject: [PATCH] -bug 259 fixed: optimize parse_comment_content() including links git-svn-id: http://piwigo.org/svn/branches/branch-1_5@1002 68402e56-0260-453c-a942-63ccdbb3a9ee --- include/functions_html.inc.php | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/include/functions_html.inc.php b/include/functions_html.inc.php index ca8ae53e1..50a999854 100644 --- a/include/functions_html.inc.php +++ b/include/functions_html.inc.php @@ -401,21 +401,25 @@ function get_html_menu_category($categories) function parse_comment_content($content) { $content = nl2br($content); + + $pattern = '/(http?:\/\/\S*)/'; + $replacement = '$1'; + $content = preg_replace($pattern, $replacement, $content); // replace _word_ by an underlined word - $pattern = '/_([^\s]*)_/'; - $replacement = '\1'; + $pattern = '/\b_(\S*)_\b/'; + $replacement = '$1'; $content = preg_replace($pattern, $replacement, $content); // replace *word* by a bolded word - $pattern = '/\*([^\s]*)\*/'; - $replacement = '\1'; + $pattern = '/\b\*(\S*)\*\b/'; + $replacement = '$1'; $content = preg_replace($pattern, $replacement, $content); // replace /word/ by an italic word - $pattern = '/\/([^\s]*)\//'; - $replacement = '\1'; - $content = preg_replace($pattern, $replacement, $content); + $pattern = "/\/(\S*)\/(\s)/"; + $replacement = '$1$2'; + $content = preg_replace($pattern, $replacement, $content); return $content; }