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 26d20b6 commit 5945edd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion cake/libs/view/helpers/text.php
Expand Up @@ -123,7 +123,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);
}

/**
Expand Down
8 changes: 6 additions & 2 deletions cake/tests/cases/libs/view/helpers/text.test.php
Expand Up @@ -267,15 +267,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);
}

/**
Expand Down

0 comments on commit 5945edd

Please sign in to comment.