Permalink
Browse files

Fix double encoding in JsHelper request methods.

The urls were being HTML & URL encoded, this causes issues with URL's
containing query string parameters.  Remove HTML entities as they aren't
required in the Javascript context.

Fixes #3495
  • Loading branch information...
1 parent a949988 commit 75f654b87bc91286baae58eb89f3f5d04cf20e13 @markstory markstory committed Jan 3, 2013
@@ -216,6 +216,18 @@ public function testRequest() {
}
/**
+ * Test that querystring arguments are not double escaped.
+ *
+ * @return void
+ */
+ public function testRequestWithQueryStringArguments() {
+ $url = '/users/search/sort:User.name/direction:desc?nome=&cpm=&audience=public';
+ $result = $this->Jquery->request($url);
+ $expected = '$.ajax({url:"\\/users\\/search\\/sort:User.name\\/direction:desc?nome=&cpm=&audience=public"});';
+ $this->assertEquals($expected, $result);
+ }
+
+/**
* test that alternate jQuery object values work for request()
*
* @return void
@@ -250,7 +250,7 @@ public function effect($name, $options = array()) {
* @see JsBaseEngineHelper::request() for options list.
*/
public function request($url, $options = array()) {
- $url = $this->url($url);
+ $url = html_entity_decode($this->url($url), ENT_COMPAT, Configure::read('App.encoding'));
$options = $this->_mapOptions('request', $options);
if (isset($options['data']) && is_array($options['data'])) {
$options['data'] = $this->_toQuerystring($options['data']);
@@ -234,7 +234,7 @@ public function effect($name, $options = array()) {
* @return string The completed ajax call.
*/
public function request($url, $options = array()) {
- $url = $this->url($url);
+ $url = html_entity_decode($this->url($url), ENT_COMPAT, Configure::read('App.encoding'));
$options = $this->_mapOptions('request', $options);
$type = $data = null;
if (isset($options['type']) || isset($options['update'])) {
@@ -234,7 +234,8 @@ public function effect($name, $options = array()) {
* @return string The completed ajax call.
*/
public function request($url, $options = array()) {
- $url = '"' . $this->url($url) . '"';
+ $url = html_entity_decode($this->url($url), ENT_COMPAT, Configure::read('App.encoding'));
+ $url = '"' . $url . '"';
$options = $this->_mapOptions('request', $options);
$type = '.Request';
if (isset($options['type']) && strtolower($options['type']) == 'json') {

0 comments on commit 75f654b

Please sign in to comment.