#!/usr/bin/perl
+package IkiWiki;
+
use warnings;
use strict;
use IkiWiki;
use open qw{:utf8 :std};
use Encode;
-package IkiWiki;
-
sub printheader ($) { #{{{
my $session=shift;
# This untaint is safe because we check file_pruned.
my $page=$form->field('page');
$page=possibly_foolish_untaint($page);
+ my $absolute=($page =~ s#^/+##);
if (! defined $page || ! length $page ||
- file_pruned($page, $config{srcdir}) || $page=~/^\//) {
+ file_pruned($page, $config{srcdir})) {
error("bad page name");
}
if (! defined $from || ! length $from ||
$from ne $form->field('from') ||
file_pruned($from, $config{srcdir}) ||
- $from=~/^\// ||
+ $from=~/^\// ||
+ $absolute ||
$form->submitted eq "Preview") {
@page_locs=$best_loc=$page;
}
CGI::Session->name("ikiwiki_session_".encode_utf8($config{wikiname}));
my $oldmask=umask(077);
- my $session = CGI::Session->new("driver:DB_File", $q,
- { FileName => "$config{wikistatedir}/sessions.db" });
+ my $session = eval {
+ CGI::Session->new("driver:DB_File", $q,
+ { FileName => "$config{wikistatedir}/sessions.db" })
+ };
+ if (! $session || $@) {
+ error($@." ".CGI::Session->errstr());
+ }
+
umask($oldmask);
return $session;