Skip to content

Commit

Permalink
Revert "Fixing escaping of forward slash for JS Engines."
Browse files Browse the repository at this point in the history
This reverts commit 7334fdf.
  • Loading branch information
predominant committed Mar 9, 2010
1 parent 7d81d81 commit 2218d18
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
15 changes: 8 additions & 7 deletions cake/libs/view/helpers/js.php
Expand Up @@ -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)):
Expand Down
12 changes: 6 additions & 6 deletions cake/tests/cases/libs/view/helpers/jquery_engine.test.php
Expand Up @@ -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(
Expand All @@ -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(
Expand All @@ -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(
Expand All @@ -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(
Expand All @@ -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);
}

Expand Down

0 comments on commit 2218d18

Please sign in to comment.