Fixing linking of emails that are missing tld's. They should not be turned into links. Test added. Fixes #1622

This commit is contained in:
mark_story 2011-03-27 19:09:46 -04:00
parent 249607654b
commit fbab7bd9c3
2 changed files with 12 additions and 1 deletions

View file

@ -145,7 +145,7 @@ class TextHelper extends AppHelper {
$atom = '[a-z0-9!#$%&\'*+\/=?^_`{|}~-]';
return preg_replace_callback(
'/(' . $atom . '+(?:\.' . $atom . '+)*@[a-z0-9-]+(?:\.[a-z0-9-]+)*)/i',
'/(' . $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],' . $linkOptions . ');'), $text);
}

View file

@ -320,6 +320,17 @@ class TextHelperTest extends CakeTestCase {
$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
*