Skip to content

Commit

Permalink
fix security problems in draft handling. fixes #3565
Browse files Browse the repository at this point in the history
  • Loading branch information
splitbrain committed Dec 17, 2021
1 parent ecad51d commit 2420159
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
6 changes: 4 additions & 2 deletions inc/Ajax.php
Expand Up @@ -168,8 +168,10 @@ protected function callDraftdel() {
$client = $_SERVER['REMOTE_USER'];
if(!$client) $client = clientIP(true);

$cname = getCacheName($client . $id, '.draft');
@unlink($cname);
$draft = new Draft($id, $client);
if ($draft->isDraftAvailable() && checkSecurityToken()) {
$draft->deleteDraft();
}
}

/**
Expand Down
2 changes: 1 addition & 1 deletion inc/Draft.php
Expand Up @@ -25,7 +25,7 @@ public function __construct($ID, $client)
{
$this->id = $ID;
$this->client = $client;
$this->cname = getCacheName($client.$ID, '.draft');
$this->cname = getCacheName("$client\n$ID", '.draft');
if(file_exists($this->cname) && file_exists(wikiFN($ID))) {
if (filemtime($this->cname) < filemtime(wikiFN($ID))) {
// remove stale draft
Expand Down
3 changes: 2 additions & 1 deletion lib/scripts/edit.js
Expand Up @@ -210,7 +210,8 @@ function deleteDraft() {
jQuery.post(DOKU_BASE + 'lib/exe/ajax.php',
{
call: 'draftdel',
id: $dwform.find('input[name=id]').val()
id: $dwform.find('input[name=id]').val(),
sectok: $dwform.find('input[name=sectok]').val()
}
);
}
Expand Down

0 comments on commit 2420159

Please sign in to comment.