From 3e8123868e987b9d220b4514e73434651831a6cf Mon Sep 17 00:00:00 2001 From: ADmad Date: Sat, 25 Jun 2016 19:04:50 +0530 Subject: [PATCH] Fix auto linking for URLs with uppercased protocol. Closes #9033 --- src/View/Helper/TextHelper.php | 2 +- tests/TestCase/View/Helper/TextHelperTest.php | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/View/Helper/TextHelper.php b/src/View/Helper/TextHelper.php index f62acbef229..e083b73ab63 100644 --- a/src/View/Helper/TextHelper.php +++ b/src/View/Helper/TextHelper.php @@ -162,7 +162,7 @@ protected function _linkUrls($text, $htmlOptions) $replace = []; foreach ($this->_placeholders as $hash => $url) { $link = $url; - if (!preg_match('#^[a-z]+\://#', $url)) { + if (!preg_match('#^[a-z]+\://#i', $url)) { $url = 'http://' . $url; } $replace[$hash] = $this->Html->link($link, $url, $htmlOptions); diff --git a/tests/TestCase/View/Helper/TextHelperTest.php b/tests/TestCase/View/Helper/TextHelperTest.php index d5dcb1eb94a..6e3cf115638 100644 --- a/tests/TestCase/View/Helper/TextHelperTest.php +++ b/tests/TestCase/View/Helper/TextHelperTest.php @@ -299,6 +299,10 @@ public static function autoLinkProvider() 'This is a test that includes www.wikipedia.org/wiki/Kanton_(Schweiz)#fragment', 'This is a test that includes www.wikipedia.org/wiki/Kanton_(Schweiz)#fragment', ], + [ + 'This is a test that includes Http://example.com/test.php?foo=bar text', + 'This is a test that includes Http://example.com/test.php?foo=bar text', + ], [ 'This is a test that includes http://example.com/test.php?foo=bar text', 'This is a test that includes http://example.com/test.php?foo=bar text',