X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/blobdiff_plain/3adb47ec4f7374128d18a88cff54269104fc21fe..9b832df0d257e3d358ead63fd865d2a6b1914e19:/IkiWiki/Plugin/remove.pm diff --git a/IkiWiki/Plugin/remove.pm b/IkiWiki/Plugin/remove.pm index a46294e78..1717c8cf3 100644 --- a/IkiWiki/Plugin/remove.pm +++ b/IkiWiki/Plugin/remove.pm @@ -42,9 +42,6 @@ sub check_canremove ($$$) { error(sprintf(gettext("%s is not a file"), $file)); } - # Must be editable. - IkiWiki::check_canedit($page, $q, $session); - # If a user can't upload an attachment, don't let them delete it. # This is sorta overkill, but better safe than sorry. if (! defined pagetype($pagesources{$page})) { @@ -74,6 +71,7 @@ sub check_canremove ($$$) { } } }); + return defined $canremove ? $canremove : 1; } sub formbuilder_setup (@) { @@ -107,6 +105,8 @@ sub confirmation_form ($$) { fields => [qw{do page}], ); + $f->field(name => "sid", type => "hidden", value => $session->id, + force => 1); $f->field(name => "do", type => "hidden", value => "remove", force => 1); return $f, ["Remove", "Cancel"]; @@ -119,6 +119,7 @@ sub removal_confirm ($$@) { my @pages=@_; foreach my $page (@pages) { + IkiWiki::check_canedit($page, $q, $session); check_canremove($page, $q, $session); } @@ -188,12 +189,15 @@ sub sessioncgi ($$) { postremove($session); } elsif ($form->submitted eq 'Remove' && $form->validate) { + IkiWiki::checksessionexpiry($q, $session, $q->param('sid')); + my @pages=$form->field("page"); # Validate removal by checking that the page exists, # and that the user is allowed to edit(/remove) it. my @files; foreach my $page (@pages) { + IkiWiki::check_canedit($page, $q, $session); check_canremove($page, $q, $session); # This untaint is safe because of the @@ -209,8 +213,10 @@ sub sessioncgi ($$) { foreach my $file (@files) { IkiWiki::rcs_remove($file); } - IkiWiki::rcs_commit_staged(gettext("removed"), - $session->param("name"), $ENV{REMOTE_ADDR}); + IkiWiki::rcs_commit_staged( + message => gettext("removed"), + session => $session, + ); IkiWiki::enable_commit_hook(); IkiWiki::rcs_update(); }