Skip to content

Commit

Permalink
Add a csrf check to the Lister bookmarks form and make markup disallo…
Browse files Browse the repository at this point in the history
…wed by default (with optional argument to enable it) in ProcessController ajax notification response generator (as used by some Lister errors).

Co-authored-by: filipaze <filipaze98@gmail.com>
Co-authored-by: rondons <guilhermetamagnini@gmail.com>
  • Loading branch information
3 people committed Sep 12, 2022
1 parent f6558c2 commit 95bdbf7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
9 changes: 6 additions & 3 deletions wire/core/ProcessController.php
Expand Up @@ -81,6 +81,7 @@ class ProcessController extends Wire {
*
*/
public function __construct() {
parent::__construct();
$this->prefix = 'Process';
$this->processMethodName = ''; // blank indicates default/index method
}
Expand Down Expand Up @@ -463,13 +464,15 @@ protected function getViewFile(Process $process, $method = '') {
*
* @param string $msg
* @param bool $error
* @param bool $allowMarkup
* @return string JSON encoded string
*
*/
public function jsonMessage($msg, $error = false) {
public function jsonMessage($msg, $error = false, $allowMarkup = false) {
if(!$allowMarkup) $msg = $this->wire()->sanitizer->entities($msg);
return json_encode(array(
'error' => $error,
'message' => $msg
'error' => (bool) $error,
'message' => (string) $msg
));
}

Expand Down
Expand Up @@ -445,6 +445,7 @@ public function executeEditBookmark() {

$deleteBookmarkID = $this->bookmarks->_bookmarkID($input->post('delete_bookmark'));
if($deleteBookmarkID) {
$session->CSRF()->validate();
if($this->bookmarks->deleteBookmarkByID($deleteBookmarkID)) {
$this->message($this->_('Deleted bookmark'));
} else {
Expand All @@ -455,7 +456,9 @@ public function executeEditBookmark() {
}

if($input->post('bookmark_title')) {
return $this->executeSaveBookmark();
$session->CSRF()->validate();
$this->executeSaveBookmark();
return '';
}

$bookmarkID = $this->bookmarks->_bookmarkID($input->get('bookmark'));
Expand Down

0 comments on commit 95bdbf7

Please sign in to comment.