Browse Source

also fix autoLinkEmail()

euromark 12 years ago
parent
commit
205f7a504b

+ 5 - 0
lib/Cake/Test/Case/View/Helper/TextHelperTest.php

@@ -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);
 	}
 
 /**

+ 2 - 2
lib/Cake/View/Helper/TextHelper.php

@@ -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
 		);