also fix autoLinkEmail()

This commit is contained in:
euromark 2013-09-27 14:56:53 +02:00
parent 2a954b6095
commit 205f7a504b
2 changed files with 7 additions and 2 deletions

View file

@ -359,6 +359,11 @@ class TextHelperTest extends CakeTestCase {
$expected = 'Text with <a href="mailto:email@example.com" \s*class="link">email@example.com</a> address';
$result = $this->Text->autoLinkEmails($text, array('class' => 'link'));
$this->assertRegExp('#^' . $expected . '$#', $result);
$text = 'Text with düsentrieb@küchenschöhn-not-working.de address';
$expected = 'Text with <a href="mailto:düsentrieb@küchenschöhn-not-working.de">düsentrieb@küchenschöhn-not-working.de</a> address';
$result = $this->Text->autoLinkEmails($text);
$this->assertRegExp('#^' . $expected . '$#', $result);
}
/**

View file

@ -186,9 +186,9 @@ class TextHelper extends AppHelper {
$options += array('escape' => true);
$this->_placeholders = array();
$atom = '[a-z0-9!#$%&\'*+\/=?^_`{|}~-]';
$atom = '[\p{L}0-9!#$%&\'*+\/=?^_`{|}~-]';
$text = preg_replace_callback(
'/(' . $atom . '+(?:\.' . $atom . '+)*@[a-z0-9-]+(?:\.[a-z0-9-]+)+)/i',
'/(' . $atom . '+(?:\.' . $atom . '+)*@[\p{L}0-9-]+(?:\.[a-z0-9-]+)+)/ui',
array(&$this, '_insertPlaceholder'),
$text
);