Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
update
  • Loading branch information
peter-mw committed Feb 19, 2022
1 parent 4b0cf30 commit fa427b2
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
17 changes: 17 additions & 0 deletions src/MicroweberPackages/App/tests/LiveEditTest.php
Expand Up @@ -94,5 +94,22 @@ public function testSaveContentOnPage()
$this->assertTrue(str_contains($html, $contentFieldHtml));




$response = $this->call(
'POST',
route('api.content.save_edit'),
[
'data_base64' => 'somethingthatisnotbase64',
],
[],//params
$_COOKIE,//cookie
[],//files
$_SERVER //server
);
$fieldSaved = $response->decodeResponseJson();
$this->assertArrayHasKey( 'error',$fieldSaved);


}
}
9 changes: 8 additions & 1 deletion src/MicroweberPackages/Content/ContentManagerHelpers.php
Expand Up @@ -627,9 +627,16 @@ public function save_from_live_edit($post_data)
}

$post_data['json_obj'] = @base64_decode($post_data['data_base64']);
if($post_data['json_obj'] == false){
return array('error' => 'The invalid data was sent');
}

}
if (isset($post_data['json_obj'])) {
$obj = json_decode($post_data['json_obj'], true);
$obj = @json_decode($post_data['json_obj'], true);
if($obj == false){
return array('error' => 'The invalid data was sent');
}
$post_data = $obj;
}
if (isset($post_data['mw_preview_only'])) {
Expand Down

0 comments on commit fa427b2

Please sign in to comment.