Browse files

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

This reverts commit 7334fdf.
  • Loading branch information...
1 parent 7d81d81 commit 2218d186c83c8e20a3c6cdf79e49141c597b5a3d @predominant predominant committed Mar 9, 2010
Showing with 14 additions and 13 deletions.
  1. +8 −7 cake/libs/view/helpers/js.php
  2. +6 −6 cake/tests/cases/libs/view/helpers/jquery_engine.test.php
View
15 cake/libs/view/helpers/js.php
@@ -676,23 +676,24 @@ function _utf8ToHex($string) {
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
12 cake/tests/cases/libs/view/helpers/jquery_engine.test.php
@@ -156,13 +156,13 @@ function testEffect() {
*/
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 @@ function testRequest() {
'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 @@ function testRequest() {
'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 @@ function testRequest() {
'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 @@ function testRequest() {
'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);
}

0 comments on commit 2218d18

Please sign in to comment.