Permalink
Browse files

Removing strtolower call that was breaking autolinks for URL shortene…

…rs. Tests added. Fixes #838
  • Loading branch information...
1 parent 418b8e5 commit 6fa4ce586ff03ecc14a1ac35f4042b306885c5ae @markstory markstory committed Jun 22, 2010
Showing with 9 additions and 5 deletions.
  1. +2 −2 cake/libs/view/helpers/text.php
  2. +7 −3 cake/tests/cases/libs/view/helpers/text.test.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
*/
}
-?>
+?>
@@ -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');
}
}
-?>
+?>

0 comments on commit 6fa4ce5

Please sign in to comment.