diff --git a/lib/Cake/Test/Case/View/Helper/TextHelperTest.php b/lib/Cake/Test/Case/View/Helper/TextHelperTest.php index 6b5d86621..73c021c74 100644 --- a/lib/Cake/Test/Case/View/Helper/TextHelperTest.php +++ b/lib/Cake/Test/Case/View/Helper/TextHelperTest.php @@ -363,10 +363,25 @@ class TextHelperTest extends CakeTestCase { $result = $this->Text->autoLinkUrls($text); $this->assertEquals($expected, $result); - $text = 'Text with email@example.com address'; - $expected = 'Text with email@example.com address'; + $text = 'email@example.com address'; + $expected = 'email@example.com address'; $result = $this->Text->autoLinkEmails($text); - $this->assertRegExp('#^' . $expected . '$#', $result); + $this->assertEquals($expected, $result); + + $text = 'email@example.com address'; + $expected = 'email@example.com address'; + $result = $this->Text->autoLinkEmails($text); + $this->assertEquals($expected, $result); + + $text = '(email@example.com) address'; + $expected = '(email@example.com) address'; + $result = $this->Text->autoLinkEmails($text); + $this->assertEquals($expected, $result); + + $text = 'Text with email@example.com address'; + $expected = 'Text with email@example.com address'; + $result = $this->Text->autoLinkEmails($text); + $this->assertEquals($expected, $result); $text = "Text with o'hare._-bob@example.com address"; $expected = 'Text with o'hare._-bob@example.com address'; @@ -374,19 +389,19 @@ class TextHelperTest extends CakeTestCase { $this->assertEquals($expected, $result); $text = 'Text with email@example.com address'; - $expected = 'Text with email@example.com address'; + $expected = 'Text with email@example.com address'; $result = $this->Text->autoLinkEmails($text, array('class' => 'link')); - $this->assertRegExp('#^' . $expected . '$#', $result); + $this->assertEquals($expected, $result); $text = 'Text with düsentrieb@küchenschöhn-not-working.de address'; $expected = 'Text with düsentrieb@küchenschöhn-not-working.de address'; $result = $this->Text->autoLinkEmails($text); - $this->assertRegExp('#^' . $expected . '$#', $result); + $this->assertEquals($expected, $result); $text = 'Text with me@subdomain.küchenschöhn.de address'; $expected = 'Text with me@subdomain.küchenschöhn.de address'; $result = $this->Text->autoLinkEmails($text); - $this->assertRegExp('#^' . $expected . '$#', $result); + $this->assertEquals($expected, $result); } /** diff --git a/lib/Cake/View/Helper/TextHelper.php b/lib/Cake/View/Helper/TextHelper.php index c418a54de..a3f07856c 100644 --- a/lib/Cake/View/Helper/TextHelper.php +++ b/lib/Cake/View/Helper/TextHelper.php @@ -187,7 +187,7 @@ class TextHelper extends AppHelper { $atom = '[\p{L}0-9!#$%&\'*+\/=?^_`{|}~-]'; $text = preg_replace_callback( - '/(?<=\s)(' . $atom . '*(?:\.' . $atom . '+)*@[\p{L}0-9-]+(?:\.[\p{L}0-9-]+)+)/ui', + '/(?<=\s|^|\()(' . $atom . '*(?:\.' . $atom . '+)*@[\p{L}0-9-]+(?:\.[\p{L}0-9-]+)+)/ui', array(&$this, '_insertPlaceholder'), $text );