Fixing entity encoding of url strings inside remoteFunctions contained in safe CDATA blocks. Fixes #127

This commit is contained in:
Mark Story 2010-02-08 23:07:13 -05:00
parent 2cf294a749
commit 0fda18d11c
2 changed files with 16 additions and 1 deletions

View file

@ -212,6 +212,7 @@ class AjaxHelper extends AppHelper {
unset($confirm);
}
$htmlOptions = $this->__getHtmlOptions($options, array('url'));
$options += array('safe' => true);
if (empty($options['fallback']) || !isset($options['fallback'])) {
$options['fallback'] = $href;
@ -257,7 +258,14 @@ class AjaxHelper extends AppHelper {
$func = "new Ajax.Request(";
}
$func .= "'" . $this->url(isset($options['url']) ? $options['url'] : "") . "'";
$url = isset($options['url']) ? $options['url'] : "";
if (empty($options['safe'])) {
$url = $this->url($url);
} else {
$url = Router::url($url);
}
$func .= "'" . $url . "'";
$func .= ", " . $this->__optionsForAjax($options) . ")";
if (isset($options['before'])) {

View file

@ -557,6 +557,13 @@ class AjaxHelperTest extends CakeTestCase {
$this->assertPattern("/Event.observe\('link[0-9]+', [\w\d,'\(\)\s{}]+Ajax\.Request\([\w\d\s,'\(\){}:\/]+onComplete:function\(request, json\) {test}/", $result);
$this->assertNoPattern('/^<a[^<>]+complete="test"[^<>]*>Ajax Link<\/a>/', $result);
$this->assertNoPattern('/^<a\s+[^<>]*url="[^"]*"[^<>]*>/', $result);
$result = $this->Ajax->link(
'Ajax Link',
array('controller' => 'posts', 'action' => 'index', '?' => array('one' => '1', 'two' => '2')),
array('update' => 'myDiv', 'id' => 'myLink')
);
$this->assertPattern('#/posts/\?one\=1\&two\=2#', $result);
}
/**
* testRemoteTimer method