+ 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
+ # checks performed above, which verify the
+ # page is a normal file, etc.
+ push @files, IkiWiki::possibly_foolish_untaint($pagesources{$page});
+ }
+
+ # Do removal, and update the wiki.
+ require IkiWiki::Render;
+ if ($config{rcs}) {
+ IkiWiki::disable_commit_hook();
+ foreach my $file (@files) {
+ IkiWiki::rcs_remove($file);
+ }
+ IkiWiki::rcs_commit_staged(
+ message => gettext("removed"),
+ session => $session,
+ );
+ IkiWiki::enable_commit_hook();
+ IkiWiki::rcs_update();
+ }
+ else {
+ foreach my $file (@files) {
+ IkiWiki::prune("$config{srcdir}/$file");
+ }
+ }
+ IkiWiki::refresh();
+ IkiWiki::saveindex();
+
+ if ($q->param("attachment")) {
+ # Attachments were deleted, so redirect
+ # back to the edit form.
+ postremove($session);
+ }
+ else {
+ # The page is gone, so redirect to parent
+ # of the page.
+ my $parent=IkiWiki::dirname($pages[0]);
+ if (! exists $pagesources{$parent}) {
+ $parent="index";
+ }
+ IkiWiki::redirect($q, urlto($parent, '/', 1));
+ }