Skip to content

Commit

Permalink
Make TextHelper::autoLink() work properly with umlauts.
Browse files Browse the repository at this point in the history
  • Loading branch information
euromark committed Sep 27, 2013
1 parent ad1b806 commit 2a954b6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
16 changes: 12 additions & 4 deletions lib/Cake/Test/Case/View/Helper/TextHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'
)
);
}

Expand Down Expand Up @@ -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
Expand All @@ -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.
Expand All @@ -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.
Expand All @@ -415,7 +423,7 @@ public function testAutoParagraph() {
TEXT;
$result = $this->Text->autoParagraph($text);
$this->assertEquals($expected, $result);
$this->assertTextEquals($expected, $result);
}

}
2 changes: 1 addition & 1 deletion lib/Cake/View/Helper/TextHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand Down

0 comments on commit 2a954b6

Please sign in to comment.