mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 11:28:25 +00:00
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
This commit is contained in:
parent
a949988208
commit
75f654b87b
4 changed files with 16 additions and 3 deletions
|
@ -215,6 +215,18 @@ class JqueryEngineHelperTest extends CakeTestCase {
|
|||
$this->assertEquals($expected, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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()
|
||||
*
|
||||
|
|
|
@ -250,7 +250,7 @@ class JqueryEngineHelper extends JsBaseEngineHelper {
|
|||
* @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 @@ class MootoolsEngineHelper extends JsBaseEngineHelper {
|
|||
* @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 @@ class PrototypeEngineHelper extends JsBaseEngineHelper {
|
|||
* @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') {
|
||||
|
|
Loading…
Reference in a new issue