Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
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...
commit 446a6a0a1aa30825be1a243dd1c33aee87c62d9a 1 parent 8a88301
@markstory markstory authored
View
2  cake/libs/view/helpers/text.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);
}
/**
View
11 cake/tests/cases/libs/view/helpers/text.test.php
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.