Changeset 33022
- Timestamp:
- 09/15/11 07:27:12 (2 years ago)
- Files:
-
- branches/1.4/lib/helper/TextHelper.php (modified) (1 diff)
- branches/1.4/test/unit/helper/TextHelperTest.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/1.4/lib/helper/TextHelper.php
r31895 r33022 284 284 function _auto_link_email_addresses($text) 285 285 { 286 return preg_replace('/([\w\.!#\$%\-+.]+@[A-Za-z0-9\-]+(\.[A-Za-z0-9\-]+)+)/', '<a href="mailto:\\1">\\1</a>', $text); 287 } 286 // Taken from http://snippets.dzone.com/posts/show/6156 287 return preg_replace("#(^|[\n ])([a-z0-9&\-_\.]+?)@([\w\-]+\.([\w\-\.]+\.)*[\w]+)#i", "\\1<a href=\"mailto:\\2@\\3\">\\2@\\3</a>", $text); 288 289 // Removed since it destroys already linked emails 290 // Example: <a href="mailto:me@example.com">bar</a> gets <a href="mailto:me@example.com">bar</a> gets <a href="mailto:<a href="mailto:me@example.com">bar</a> 291 //return preg_replace('/([\w\.!#\$%\-+.]+@[A-Za-z0-9\-]+(\.[A-Za-z0-9\-]+)+)/', '<a href="mailto:\\1">\\1</a>', $text); 292 } branches/1.4/test/unit/helper/TextHelperTest.php
r31895 r33022 14 14 require_once(dirname(__FILE__).'/../../../lib/helper/TextHelper.php'); 15 15 16 $t = new lime_test(5 4);16 $t = new lime_test(56); 17 17 18 18 // truncate_text() … … 135 135 $t->is(auto_link_text('<p>http://twitter.com/#!/fabpot</p>'),'<p><a href="http://twitter.com/#!/fabpot">http://twitter.com/#!/fabpot</a></p>',"auto_link_text() converts URLs with complex fragments to links"); 136 136 $t->is(auto_link_text('<p>http://twitter.com/#!/fabpot is Fabien Potencier on Twitter</p>'),'<p><a href="http://twitter.com/#!/fabpot">http://twitter.com/#!/fabpot</a> is Fabien Potencier on Twitter</p>',"auto_link_text() converts URLs with complex fragments and trailing text to links"); 137 137 $t->is(auto_link_text('hello '.$email_result, 'email_addresses'), 'hello '.$email_result, "auto_link_text() does not double-link emails"); 138 $t->is(auto_link_text('<p>Link '.$link_result.'</p>'), '<p>Link '.$link_result.'</p>', "auto_link_text() does not double-link emails");