Revert "Fixing escaping of forward slash for JS Engines."

This reverts commit 7334fdfbdf.
This commit is contained in:
predominant 2010-03-09 14:30:28 +11:00
parent 7d81d81176
commit 2218d186c8
2 changed files with 14 additions and 13 deletions

View file

@ -676,23 +676,24 @@ class JsBaseEngineHelper extends AppHelper {
for ($i = 0; $i < $length; ++$i) {
$ord = ord($string{$i});
switch (true) {
case $ord == 0x08: // Backspace
case $ord == 0x08:
$return .= '\b';
break;
case $ord == 0x09: // Tab
case $ord == 0x09:
$return .= '\t';
break;
case $ord == 0x0A: // New Line
case $ord == 0x0A:
$return .= '\n';
break;
case $ord == 0x0C: // New Page
case $ord == 0x0C:
$return .= '\f';
break;
case $ord == 0x0D: // Carriage Return
case $ord == 0x0D:
$return .= '\r';
break;
case $ord == 0x22: // Character: "
case $ord == 0x5C: // Character: \
case $ord == 0x22:
case $ord == 0x2F:
case $ord == 0x5C:
$return .= '\\' . $string{$i};
break;
case (($ord >= 0x20) && ($ord <= 0x7F)):

View file

@ -156,13 +156,13 @@ class JqueryEngineHelperTestCase extends CakeTestCase {
*/
function testRequest() {
$result = $this->Jquery->request(array('controller' => 'posts', 'action' => 'view', 1));
$expected = '$.ajax({url:"/posts/view/1"});';
$expected = '$.ajax({url:"\\/posts\\/view\\/1"});';
$this->assertEqual($result, $expected);
$result = $this->Jquery->request(array('controller' => 'posts', 'action' => 'view', 1), array(
'update' => '#content'
));
$expected = '$.ajax({dataType:"html", success:function (data, textStatus) {$("#content").html(data);}, url:"/posts/view/1"});';
$expected = '$.ajax({dataType:"html", success:function (data, textStatus) {$("#content").html(data);}, url:"\/posts\/view\/1"});';
$this->assertEqual($result, $expected);
$result = $this->Jquery->request('/people/edit/1', array(
@ -175,7 +175,7 @@ class JqueryEngineHelperTestCase extends CakeTestCase {
'data' => array('name' => 'jim', 'height' => '185cm'),
'wrapCallbacks' => false
));
$expected = '$.ajax({beforeSend:doBefore, complete:doComplete, data:"name=jim&height=185cm", dataType:"json", error:handleError, success:doSuccess, type:"post", url:"/people/edit/1"});';
$expected = '$.ajax({beforeSend:doBefore, complete:doComplete, data:"name=jim&height=185cm", dataType:"json", error:handleError, success:doSuccess, type:"post", url:"\\/people\\/edit\\/1"});';
$this->assertEqual($result, $expected);
$result = $this->Jquery->request('/people/edit/1', array(
@ -184,7 +184,7 @@ class JqueryEngineHelperTestCase extends CakeTestCase {
'method' => 'post',
'wrapCallbacks' => false
));
$expected = '$.ajax({dataType:"html", success:function (data, textStatus) {$("#updated").html(data);}, type:"post", url:"/people/edit/1"});';
$expected = '$.ajax({dataType:"html", success:function (data, textStatus) {$("#updated").html(data);}, type:"post", url:"\\/people\\/edit\\/1"});';
$this->assertEqual($result, $expected);
$result = $this->Jquery->request('/people/edit/1', array(
@ -195,7 +195,7 @@ class JqueryEngineHelperTestCase extends CakeTestCase {
'data' => '$("#someId").serialize()',
'wrapCallbacks' => false
));
$expected = '$.ajax({data:$("#someId").serialize(), dataType:"html", success:function (data, textStatus) {$("#updated").html(data);}, type:"post", url:"/people/edit/1"});';
$expected = '$.ajax({data:$("#someId").serialize(), dataType:"html", success:function (data, textStatus) {$("#updated").html(data);}, type:"post", url:"\\/people\\/edit\\/1"});';
$this->assertEqual($result, $expected);
$result = $this->Jquery->request('/people/edit/1', array(
@ -205,7 +205,7 @@ class JqueryEngineHelperTestCase extends CakeTestCase {
'dataExpression' => true,
'data' => '$("#someId").serialize()',
));
$expected = '$.ajax({beforeSend:function (XMLHttpRequest) {doBefore}, data:$("#someId").serialize(), success:function (data, textStatus) {doFoo}, type:"post", url:"/people/edit/1"});';
$expected = '$.ajax({beforeSend:function (XMLHttpRequest) {doBefore}, data:$("#someId").serialize(), success:function (data, textStatus) {doFoo}, type:"post", url:"\\/people\\/edit\\/1"});';
$this->assertEqual($result, $expected);
}