From b32edfe378f467531c24b432bc46283035682515 Mon Sep 17 00:00:00 2001 From: euromark Date: Tue, 12 Jun 2012 16:30:37 +0200 Subject: [PATCH] fix double-encoding of external urls --- lib/Cake/Test/Case/View/Helper/HtmlHelperTest.php | 4 ++++ lib/Cake/View/Helper/HtmlHelper.php | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/Cake/Test/Case/View/Helper/HtmlHelperTest.php b/lib/Cake/Test/Case/View/Helper/HtmlHelperTest.php index 2a794dcabde..6f4f1304afa 100644 --- a/lib/Cake/Test/Case/View/Helper/HtmlHelperTest.php +++ b/lib/Cake/Test/Case/View/Helper/HtmlHelperTest.php @@ -333,6 +333,10 @@ public function testLink() { '/a' ); $this->assertTags($result, $expected); + + $result = $this->Html->link('http://www.example.org?param1=value1¶m2=value2'); + $expected = array('a' => array('href' => 'http://www.example.org?param1=value1&param2=value2'), 'http://www.example.org?param1=value1&param2=value2', '/a'); + $this->assertTags($result, $expected); } /** diff --git a/lib/Cake/View/Helper/HtmlHelper.php b/lib/Cake/View/Helper/HtmlHelper.php index 76403007c6a..fb53cf340c1 100644 --- a/lib/Cake/View/Helper/HtmlHelper.php +++ b/lib/Cake/View/Helper/HtmlHelper.php @@ -335,7 +335,8 @@ public function link($title, $url = null, $options = array(), $confirmMessage = $url = $this->url($url); } else { $url = $this->url($title); - $title = h(urldecode($url)); + $title = htmlspecialchars_decode($url, ENT_QUOTES); + $title = h(urldecode($title)); $escapeTitle = false; }