mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 11:28:25 +00:00
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:
parent
249607654b
commit
fbab7bd9c3
2 changed files with 12 additions and 1 deletions
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue