Permalink
Browse files

Fixing linking of emails that are missing tld's. They should not be t…

…urned into links. Test added. Fixes #1622
  • Loading branch information...
1 parent 8a88301 commit 446a6a0a1aa30825be1a243dd1c33aee87c62d9a @markstory markstory committed Mar 27, 2011
Showing with 12 additions and 1 deletion.
  1. +1 −1 cake/libs/view/helpers/text.php
  2. +11 −0 cake/tests/cases/libs/view/helpers/text.test.php
@@ -127,7 +127,7 @@ function autoLinkEmails($text, $htmlOptions = array()) {
$options .= ')';
$atom = '[a-z0-9!#$%&\'*+\/=?^_`{|}~-]';
- return preg_replace_callback('/(' . $atom . '+(?:\.' . $atom . '+)*@[a-z0-9-]+(?:\.[a-z0-9-]+)*)/i',
+ return preg_replace_callback('/(' . $atom . '+(?:\.' . $atom . '+)*@[a-z0-9-]+(?:\.[a-z0-9-]+)+)/i',
create_function('$matches', '$Html = new HtmlHelper(); $Html->tags = $Html->loadConfig(); return $Html->link($matches[0], "mailto:" . $matches[0],' . $options . ');'), $text);
}
/**
@@ -300,6 +300,17 @@ function testAutoLinkEmails() {
$this->assertPattern('#^' . $expected . '$#', $result);
}
/**
+ * test invalid email addresses.
+ *
+ * @return void
+ */
+ function testAutoLinkEmailInvalid() {
+ $result = $this->Text->autoLinkEmails('this is a myaddress@gmx-de test');
+ $expected = 'this is a myaddress@gmx-de test';
+ $this->assertEqual($expected, $result);
+ }
+
+/**
* testHighlightCaseInsensitivity method
*
* @access public

0 comments on commit 446a6a0

Please sign in to comment.