Skip to content
This repository has been archived by the owner on Jan 31, 2019. It is now read-only.

Commit

Permalink
Fixed bug in autoEmail method where long urls where cutting the text …
Browse files Browse the repository at this point in the history
…to null instead of replacing email addies
  • Loading branch information
Ephigenia committed Dec 19, 2012
1 parent 2a257e7 commit f7aa553
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
9 changes: 9 additions & 0 deletions lib/ephFrame/test/view/helper/TextTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

use ephFrame\view\helper\Text;

/**
* @group helper
*/
class TextTest extends \PHPUnit_Framework_TestCase
{
public function setUp()
Expand Down Expand Up @@ -141,6 +144,12 @@ public function testAutoEmailWithAttributes()
'<a href="mailto:love@ephigenia.de" class="email">love@ephigenia.de</a>'
);
}

public function testAutoEmailWithLongDomainBug()
{
$text = 'https://www.abcdefghijklm.com';
$this->assertEquals($this->fixture->autoEmail($text), $text);
}

public function testExcerptValues()
{
Expand Down
2 changes: 1 addition & 1 deletion lib/ephFrame/view/helper/Text.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function autoEmail($text, $attributes = '')
$attributes = ' '.trim((string) $attributes);
}
return preg_replace(
'/([0-9a-zA-Z]([-.\w]*[0-9a-zA-Z])*@([0-9a-zA-Z][-\w]*[0-9a-zA-Z]\.)+[a-zA-Z]{2,9})/im',
'/([_\.0-9a-z-\w]+@([0-9a-z][0-9a-z-\w]+\.)+[a-z]{2,3})/im',
'<a href="mailto:\1"'.$attributes.'>\1</a>',
$text
);
Expand Down

0 comments on commit f7aa553

Please sign in to comment.