From: x2000habouzit Date: Mon, 1 Jan 2007 14:48:51 +0000 (+0000) Subject: merge X-Git-Tag: xorg/0.9.13~148 X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=21a41057ab5a093dcf570f0feff4e2abb272f1cf;p=platal.git merge git-svn-id: svn+ssh://murphy/home/svn/platal/trunk@1322 839d8a87-29fc-0310-9880-83ba4fa771e5 --- diff --git a/include/url_catcher.inc.php b/include/url_catcher.inc.php index b1dd3f8..91db03c 100644 --- a/include/url_catcher.inc.php +++ b/include/url_catcher.inc.php @@ -3,22 +3,22 @@ // renvoie un texte html à partir d'un texte classique // en remplacant les url par des liens (éventuellement les mails) function url_catcher($texte, $mails = true) { - $patterns = array(); - $replacement = array(); - - // url commencant par http, https ou ftp - $patterns[] = '/((?:https?|ftp):\/\/(?:\.*,*[a-z@0-9~%$£µ&i#\-+=_\/\?])*)/i'; - $replacement[] = '\\0'; - - // url commencant par www. - $patterns[] = '/(\s|^)www\.((?:\.*,*[a-z@0-9~%$£µ&i#\-+=_\/\?])*)/i'; - $replacement[] = '\\1www.\\2'; - - if ($mails) { + $patterns = array(); + $replacement = array(); + + // url commencant par http, https ou ftp + $patterns[] = '/((?:https?|ftp):\/\/(?:\.*,*[a-z@0-9~%$£µ&i#\-+=_\/\?;])*)/i'; + $replacement[] = '\\0'; + + // url commencant par www. + $patterns[] = '/(\s|^)www\.((?:\.*,*[a-z@0-9~%$£µ&i#\-+=_\/\?;])*)/i'; + $replacement[] = '\\1www.\\2'; + + if ($mails) { $patterns[] = '/(?:mailto:)?([a-z0-9.\-+_]+@([\-.+_]?[a-z0-9])+)/i'; $replacement[] = '\\0'; - } - + } + return preg_replace($patterns, $replacement, $texte); } ?>