Browse files

Fix issue with link generation and no title.

Fix urlencoded text from being displayed in text of links.

Fixes #2387
  • Loading branch information...
1 parent ab2cf59 commit 866177f37d3d03be6fa557cc3633f75223bb4c7a @markstory markstory committed Dec 19, 2011
Showing with 13 additions and 1 deletion.
  1. +12 −0 lib/Cake/Test/Case/View/Helper/HtmlHelperTest.php
  2. +1 −1 lib/Cake/View/Helper/HtmlHelper.php
View
12 lib/Cake/Test/Case/View/Helper/HtmlHelperTest.php
@@ -185,12 +185,24 @@ public function testDocType() {
* @return void
*/
public function testLink() {
+ Router::connect('/:controller/:action/*');
+
$this->Html->request->webroot = '';
$result = $this->Html->link('/home');
$expected = array('a' => array('href' => '/home'), 'preg:/\/home/', '/a');
$this->assertTags($result, $expected);
+ $result = $this->Html->link(array('action' => 'login', '<[You]>'));
+ $expected = array(
+ 'a' => array('href' => '/login/%3C%5BYou%5D%3E'),
+ 'preg:/\/login\/&lt;\[You\]&gt;/',
+ '/a'
+ );
+ $this->assertTags($result, $expected);
+
+ Router::reload();
+
$result = $this->Html->link('Posts', array('controller' => 'posts', 'action' => 'index', 'full_base' => true));
$expected = array('a' => array('href' => FULL_BASE_URL . '/posts'), 'Posts', '/a');
$this->assertTags($result, $expected);
View
2 lib/Cake/View/Helper/HtmlHelper.php
@@ -327,7 +327,7 @@ public function link($title, $url = null, $options = array(), $confirmMessage =
$url = $this->url($url);
} else {
$url = $this->url($title);
- $title = $url;
+ $title = h(urldecode($url));
$escapeTitle = false;
}

0 comments on commit 866177f

Please sign in to comment.