Permalink
Browse files

Make TextHelper::autoLink() work properly with umlauts.

  • Loading branch information...
1 parent ad1b806 commit 2a954b6095ff680d3b7672339166492e0e03ceb3 @dereuromark dereuromark committed Sep 27, 2013
Showing with 13 additions and 5 deletions.
  1. +12 −4 lib/Cake/Test/Case/View/Helper/TextHelperTest.php
  2. +1 −1 lib/Cake/View/Helper/TextHelper.php
@@ -241,6 +241,14 @@ public static function autoLinkProvider() {
'Text with a url http://www.not--work.com and more',
'Text with a url <a href="http://www.not--work.com">http://www.not--work.com</a> and more',
),
+ array(
+ 'Text with a partial www.küchenschöhn-not-working.de URL',
+ 'Text with a partial <a href="http://www.küchenschöhn-not-working.de">www.küchenschöhn-not-working.de</a> URL'
+ ),
+ array(
+ 'Text with a partial http://www.küchenschöhn-not-working.de URL',
+ 'Text with a partial <a href="http://www.küchenschöhn-not-working.de">http://www.küchenschöhn-not-working.de</a> URL'
+ )
);
}
@@ -383,7 +391,7 @@ public function testAutoParagraph() {
TEXT;
$result = $this->Text->autoParagraph($text);
- $this->assertEquals($expected, $result);
+ $this->assertTextEquals($expected, $result);
$result = $this->Text->autoParagraph($text);
$text = 'This is a <BR id="test"/><br class="test"> test text';
$expected = <<<TEXT
@@ -392,7 +400,7 @@ public function testAutoParagraph() {
TEXT;
$result = $this->Text->autoParagraph($text);
- $this->assertEquals($expected, $result);
+ $this->assertTextEquals($expected, $result);
$text = <<<TEXT
This is a test text.
This is a line return.
@@ -403,7 +411,7 @@ public function testAutoParagraph() {
TEXT;
$result = $this->Text->autoParagraph($text);
- $this->assertEquals($expected, $result);
+ $this->assertTextEquals($expected, $result);
$text = <<<TEXT
This is a test text.
@@ -415,7 +423,7 @@ public function testAutoParagraph() {
TEXT;
$result = $this->Text->autoParagraph($text);
- $this->assertEquals($expected, $result);
+ $this->assertTextEquals($expected, $result);
}
}
@@ -105,7 +105,7 @@ public function autoLinkUrls($text, $options = array()) {
$this->_placeholders = array();
$options += array('escape' => true);
- $pattern = '#(?<!href="|src="|">)((?:https?|ftp|nntp)://[a-z0-9.\-:]+(?:[/?][^\s<]*)?)#i';
+ $pattern = '#(?<!href="|src="|">)((?:https?|ftp|nntp)://[\p{L}0-9.\-:]+(?:[/?][^\s<]*)?)#ui';
$text = preg_replace_callback(
$pattern,
array(&$this, '_insertPlaceHolder'),

0 comments on commit 2a954b6

Please sign in to comment.