Skip to content
Permalink
Browse files

Fixing entity encoding of url strings inside remoteFunctions containe…

…d in safe CDATA blocks. Fixes #127
  • Loading branch information...
markstory committed Feb 9, 2010
1 parent 2cf294a commit 0fda18d11c95d285d7c0ac4064175e6d65136817
Showing with 16 additions and 1 deletion.
  1. +9 −1 cake/libs/view/helpers/ajax.php
  2. +7 −0 cake/tests/cases/libs/view/helpers/ajax.test.php
@@ -212,6 +212,7 @@ function link($title, $href = null, $options = array(), $confirm = null, $escape
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 @@ function remoteFunction($options) {
$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'])) {
@@ -557,6 +557,13 @@ function testLink() {
$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

0 comments on commit 0fda18d

Please sign in to comment.
You can’t perform that action at this time.