mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 11:28:25 +00:00
Fixing escaping of forward slash for JS Engines.
This commit is contained in:
parent
382e11ccde
commit
7334fdfbdf
2 changed files with 13 additions and 14 deletions
|
@ -676,24 +676,23 @@ class JsBaseEngineHelper extends AppHelper {
|
|||
for ($i = 0; $i < $length; ++$i) {
|
||||
$ord = ord($string{$i});
|
||||
switch (true) {
|
||||
case $ord == 0x08:
|
||||
case $ord == 0x08: // Backspace
|
||||
$return .= '\b';
|
||||
break;
|
||||
case $ord == 0x09:
|
||||
case $ord == 0x09: // Tab
|
||||
$return .= '\t';
|
||||
break;
|
||||
case $ord == 0x0A:
|
||||
case $ord == 0x0A: // New Line
|
||||
$return .= '\n';
|
||||
break;
|
||||
case $ord == 0x0C:
|
||||
case $ord == 0x0C: // New Page
|
||||
$return .= '\f';
|
||||
break;
|
||||
case $ord == 0x0D:
|
||||
case $ord == 0x0D: // Carriage Return
|
||||
$return .= '\r';
|
||||
break;
|
||||
case $ord == 0x22:
|
||||
case $ord == 0x2F:
|
||||
case $ord == 0x5C:
|
||||
case $ord == 0x22: // Character: "
|
||||
case $ord == 0x5C: // Character: \
|
||||
$return .= '\\' . $string{$i};
|
||||
break;
|
||||
case (($ord >= 0x20) && ($ord <= 0x7F)):
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue