From 17ed78c14df3f03ff8e5370bbdb5b72004b85020 Mon Sep 17 00:00:00 2001 From: "Paul S. Owen" Date: Tue, 18 Mar 2003 17:24:14 +0000 Subject: [PATCH] Problem with url matching + spaces git-svn-id: file:///svn/phpbb/trunk@3667 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/message_parser.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/phpBB/includes/message_parser.php b/phpBB/includes/message_parser.php index 91c9005615..464fb367b2 100644 --- a/phpBB/includes/message_parser.php +++ b/phpBB/includes/message_parser.php @@ -33,7 +33,7 @@ class parse_message function parse(&$message, $html, $bbcode, $uid, $url, $smilies, $attach = false) { - global $config, $db, $user, $_FILE; + global $config, $db, $user; $warn_msg = ''; @@ -132,20 +132,20 @@ class parse_message $replace = array(); // relative urls for this board - $match[] = '#' . $server_protocol . trim($config['server_name']) . $server_port . preg_replace('/^\/?(.*?)(\/)?$/', '\1', trim($config['script_path'])) . '/([^\t\n\r <"\']+)#i'; + $match[] = '#' . $server_protocol . trim($config['server_name']) . $server_port . preg_replace('/^\/?(.*?)(\/)?$/', '\1', trim($config['script_path'])) . '/([^ \t\n\r <"\']+)#i'; $replace[] = '\1'; // matches a xxxx://aaaaa.bbb.cccc. ... - $match[] = '#(^|[\n ])([\w]+?://.*?[^\t\n\r<"]*)#ie'; - $replace[] = "'\\1' . ( ( strlen(str_replace(' ', '%20', '\\2')) > 55 ) ?substr(str_replace(' ', '%20', '\\2'), 0, 39) . ' ... ' . substr(str_replace(' ', '%20', '\\2'), -10) : str_replace(' ', '%20', '\\2') ) . ''"; + $match[] = '#(^|[\n ])([\w]+?://.*?[^ \t\n\r<"]*)#ie'; + $replace[] = "'\\1' . ((strlen('\\2') > 55) ? substr('\\2', 0, 39) . ' ... ' . substr('\\2', -10) : '\\2') . ''"; // matches a "www.xxxx.yyyy[/zzzz]" kinda lazy URL thing - $match[] = '#(^|[\n ])(www\.[\w\-]+\.[\w\-.\~]+(?:/[^\t\n\r<"]*)?)#ie'; - $replace[] = "'\\1' . ( ( strlen(str_replace(' ', '%20', '\\2')) > 55 ) ? substr(str_replace(' ', '%20', '\\2'), 0, 39) . ' ... ' . substr(str_replace(' ', '%20', '\\2'), -10) : str_replace(' ', '%20', '\\2') ) . ''"; + $match[] = '#(^|[\n ])(www\.[\w\-]+\.[\w\-.\~]+(?:/[^ \t\n\r<"]*)?)#ie'; + $replace[] = "'\\1' . ((strlen('\\2') > 55) ? substr(str_replace(' ', '%20', '\\2'), 0, 39) . ' ... ' . substr('\\2', -10) : '\\2') . ''"; // matches an email@domain type address at the start of a line, or after a space. $match[] = '#(^|[\n ])([a-z0-9&\-_.]+?@[\w\-]+\.([\w\-\.]+\.)?[\w]+)#ie'; - $replace[] = "'\\1' . ( ( strlen('\\2') > 55 ) ?substr('\\2', 0, 39) . ' ... ' . substr('\\2', -10) : '\\2' ) . ''"; + $replace[] = "'\\1' . ((strlen('\\2') > 55) ? substr('\\2', 0, 39) . ' ... ' . substr('\\2', -10) : '\\2') . ''"; $message = preg_replace($match, $replace, $message); }