Improve email catcher
authorx2003bruneau <x2003bruneau@9869982d-c50d-0410-be91-f2a2ec7c7c7b>
Sat, 22 Jul 2006 20:00:56 +0000 (20:00 +0000)
committerFlorent Bruneau <florent.bruneau@polytechnique.org>
Fri, 4 Jan 2008 23:35:04 +0000 (00:35 +0100)
Do not catch message-id as email anymore

git-svn-id: svn+ssh://murphy/home/svn/banana/trunk@122 9869982d-c50d-0410-be91-f2a2ec7c7c7b

Changelog
banana/misc.inc.php

index 1b2c924..6aa6a12 100644 (file)
--- a/Changelog
+++ b/Changelog
@@ -1,3 +1,7 @@
+Sat, 22 Jul 2006                    Florent Bruneau <florent.bruneau@m4x.org>
+       * Impove url and email catcher
+       * Bugfix: quotes formating
+
 Sat, 15 Jul 2006                    Florent Bruneau <florent.bruneau@m4x.org>
        * New tabbed structure
        * Support of Content-ID references (multipart/related)
index f717c00..d3eeb2d 100644 (file)
@@ -571,6 +571,14 @@ function cleanurl($url)
     return '<a href="'.$url.'" title="'.$url.'">'.cutlink($url).'</a>';
 }
 
+function catchMailLink($email)
+{
+    if (strpos($email, '$') !== false) {
+        return $email;
+    }   
+    return '<a href="mailto:' . $email . '">' . $email . '</a>';
+}
+
 /** Remove quotation marks
  */
 function replaceQuotes($text)
@@ -594,7 +602,9 @@ function formatbody($_text, $format='plain', $flowed=false)
         $url  = $banana->url_regexp;
         $res  = preg_replace("/(&lt;|&gt;|&quot;)/", " \\1 ", $res);
         $res  = preg_replace("!$url!ie", "'\\1'.cleanurl('\\2').'\\3'", $res);
-        $res  = preg_replace('/(["\[])?(?:mailto:)?([a-z0-9.\-+_]+@[a-z0-9.\-+_]+)(["\]])?/i', '\1<a href="mailto:\2">\2</a>\3', $res);
+        $res  = preg_replace('/(["\[])?(?:mailto:)?([a-z0-9.\-+_\$]+@[a-z0-9.\-+_]+)(["\]])?/ie',
+                             "'\\1' . catchMailLink('\\2') . '\\3'",
+                             $res);
         $res  = preg_replace("/ (&lt;|&gt;|&quot;) /", "\\1", $res);
 
         if ($format == 'richtext') {