Skip to content

Commit

Permalink
Removing strtolower call that was breaking autolinks for URL shortene…
Browse files Browse the repository at this point in the history
…rs. Tests added. Fixes #838
  • Loading branch information
markstory committed Jun 22, 2010
1 parent 418b8e5 commit 6fa4ce5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
4 changes: 2 additions & 2 deletions cake/libs/view/helpers/text.php
Expand Up @@ -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.
Expand Down Expand Up @@ -334,4 +334,4 @@ function flay($text, $allowHtml = false) {
* @codeCoverageIgnoreEnd
*/
}
?>
?>
10 changes: 7 additions & 3 deletions cake/tests/cases/libs/view/helpers/text.test.php
Expand Up @@ -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
Expand Down Expand Up @@ -379,4 +383,4 @@ function testListGeneration() {
$this->assertEqual($result, 'Dusty, Lucky y Ned');
}
}
?>
?>

0 comments on commit 6fa4ce5

Please sign in to comment.