From 2a954b6095ff680d3b7672339166492e0e03ceb3 Mon Sep 17 00:00:00 2001 From: euromark Date: Fri, 27 Sep 2013 14:48:57 +0200 Subject: [PATCH] Make TextHelper::autoLink() work properly with umlauts. --- .../Test/Case/View/Helper/TextHelperTest.php | 16 ++++++++++++---- lib/Cake/View/Helper/TextHelper.php | 2 +- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/lib/Cake/Test/Case/View/Helper/TextHelperTest.php b/lib/Cake/Test/Case/View/Helper/TextHelperTest.php index 887f84372..1bb27f465 100644 --- a/lib/Cake/Test/Case/View/Helper/TextHelperTest.php +++ b/lib/Cake/Test/Case/View/Helper/TextHelperTest.php @@ -241,6 +241,14 @@ class TextHelperTest extends CakeTestCase { 'Text with a url http://www.not--work.com and more', 'Text with a url http://www.not--work.com and more', ), + array( + 'Text with a partial www.küchenschöhn-not-working.de URL', + 'Text with a partial www.küchenschöhn-not-working.de URL' + ), + array( + 'Text with a partial http://www.küchenschöhn-not-working.de URL', + 'Text with a partial http://www.küchenschöhn-not-working.de URL' + ) ); } @@ -383,7 +391,7 @@ TEXT; TEXT; $result = $this->Text->autoParagraph($text); - $this->assertEquals($expected, $result); + $this->assertTextEquals($expected, $result); $result = $this->Text->autoParagraph($text); $text = 'This is a

test text'; $expected = <<Text->autoParagraph($text); - $this->assertEquals($expected, $result); + $this->assertTextEquals($expected, $result); $text = << TEXT; $result = $this->Text->autoParagraph($text); - $this->assertEquals($expected, $result); + $this->assertTextEquals($expected, $result); $text = <<Text->autoParagraph($text); - $this->assertEquals($expected, $result); + $this->assertTextEquals($expected, $result); } } diff --git a/lib/Cake/View/Helper/TextHelper.php b/lib/Cake/View/Helper/TextHelper.php index 379c89582..96d6d7098 100644 --- a/lib/Cake/View/Helper/TextHelper.php +++ b/lib/Cake/View/Helper/TextHelper.php @@ -105,7 +105,7 @@ class TextHelper extends AppHelper { $this->_placeholders = array(); $options += array('escape' => true); - $pattern = '#(?)((?:https?|ftp|nntp)://[a-z0-9.\-:]+(?:[/?][^\s<]*)?)#i'; + $pattern = '#(?)((?:https?|ftp|nntp)://[\p{L}0-9.\-:]+(?:[/?][^\s<]*)?)#ui'; $text = preg_replace_callback( $pattern, array(&$this, '_insertPlaceHolder'),