Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Removing strtolower call that was breaking autolinks for URL shortene…

…rs. Tests added. Fixes #838
  • Loading branch information...
commit 6fa4ce586ff03ecc14a1ac35f4042b306885c5ae 1 parent 418b8e5
@markstory markstory authored
View
4 cake/libs/view/helpers/text.php
@@ -108,7 +108,7 @@ function autoLinkUrls($text, $htmlOptions = array()) {
'$Html = new HtmlHelper(); $Html->tags = $Html->loadConfig(); return $Html->link($matches[0], $matches[0],' . $options . ');'), $text);
return preg_replace_callback('#(?<!href="|">)(?<!http://|https://|ftp://|nntp://)(www\.[^\n\%\ <]+[^<\n\%\,\.\ <])(?<!\))#i',
- create_function('$matches', '$Html = new HtmlHelper(); $Html->tags = $Html->loadConfig(); return $Html->link($matches[0], "http://" . strtolower($matches[0]),' . $options . ');'), $text);
+ create_function('$matches', '$Html = new HtmlHelper(); $Html->tags = $Html->loadConfig(); return $Html->link($matches[0], "http://" . $matches[0],' . $options . ');'), $text);
}
/**
* Adds email links (<a href="mailto:....) to a given text.
@@ -334,4 +334,4 @@ function flay($text, $allowHtml = false) {
* @codeCoverageIgnoreEnd
*/
}
-?>
+?>
View
10 cake/tests/cases/libs/view/helpers/text.test.php
@@ -258,15 +258,19 @@ function testAutoLinkUrls() {
$this->assertPattern('#^' . $expected . '$#', $result);
$text = 'Text with a partial WWW.cakephp.org URL';
- $expected = 'Text with a partial <a href="http://www.cakephp.org"\s*>WWW.cakephp.org</a> URL';
+ $expected = 'Text with a partial <a href="http://WWW.cakephp.org"\s*>WWW.cakephp.org</a> URL';
$result = $this->Text->autoLinkUrls($text);
$this->assertPattern('#^' . $expected . '$#', $result);
$text = 'Text with a partial WWW.cakephp.org &copy; URL';
- $expected = 'Text with a partial <a href="http://www.cakephp.org"\s*>WWW.cakephp.org</a> &copy; URL';
+ $expected = 'Text with a partial <a href="http://WWW.cakephp.org"\s*>WWW.cakephp.org</a> &copy; URL';
$result = $this->Text->autoLinkUrls($text, array('escape' => false));
$this->assertPattern('#^' . $expected . '$#', $result);
+ $text = 'Text with a url www.cot.ag/cuIb2Q and more';
+ $expected = 'Text with a url <a href="http://www.cot.ag/cuIb2Q">www.cot.ag/cuIb2Q</a> and more';
+ $result = $this->Text->autoLinkUrls($text);
+ $this->assertEqual($expected, $result);
}
/**
* testAutoLinkEmails method
@@ -379,4 +383,4 @@ function testListGeneration() {
$this->assertEqual($result, 'Dusty, Lucky y Ned');
}
}
-?>
+?>
Please sign in to comment.
Something went wrong with that request. Please try again.