aboutsummaryrefslogtreecommitdiff
path: root/IkiWiki/Receive.pm
diff options
context:
space:
mode:
authorPeter Gammie <peteg42@gmail.com>2010-10-01 14:06:00 +1000
committerPeter Gammie <peteg42@gmail.com>2010-10-01 14:06:00 +1000
commit8024a2636feb60026a79715430a66bb572b9eae8 (patch)
treeeee94edbac8195dfb2ebe269cd2d94c0a67814c9 /IkiWiki/Receive.pm
parenteba5c715144024f4784538af256ffa9d7fcb8a2d (diff)
downloadikiwiki-8024a2636feb60026a79715430a66bb572b9eae8.tar
ikiwiki-8024a2636feb60026a79715430a66bb572b9eae8.tar.gz
Complete rcs_preprevert and lightly test.
Diffstat (limited to 'IkiWiki/Receive.pm')
-rw-r--r--IkiWiki/Receive.pm32
1 files changed, 23 insertions, 9 deletions
diff --git a/IkiWiki/Receive.pm b/IkiWiki/Receive.pm
index e77c477a9..48228e5f0 100644
--- a/IkiWiki/Receive.pm
+++ b/IkiWiki/Receive.pm
@@ -48,10 +48,10 @@ EOF
sub test () {
exit 0 if trusted();
-
+
IkiWiki::lockwiki();
IkiWiki::loadindex();
-
+
# Dummy up a cgi environment to use when calling check_canedit
# and friends.
eval q{use CGI};
@@ -72,10 +72,22 @@ sub test () {
regdate => time,
}) || error("failed adding user");
}
-
- my %newfiles;
- foreach my $change (IkiWiki::rcs_receive()) {
+ test_changes(cgi => $cgi,
+ session => $session,
+ changes => [IkiWiki::rcs_receive()]
+ );
+ exit 0;
+}
+
+sub test_changes {
+ my %params = @_;
+ my $cgi = $params{cgi};
+ my $session = $params{session};
+ my @changes = @{$params{changes}};
+
+ my %newfiles;
+ foreach my $change (@changes) {
# This untaint is safe because we check file_pruned and
# wiki_file_regexp.
my ($file)=$change->{file}=~/$config{wiki_file_regexp}/;
@@ -87,7 +99,7 @@ sub test () {
my $type=pagetype($file);
my $page=pagename($file) if defined $type;
-
+
if ($change->{action} eq 'add') {
$newfiles{$file}=1;
}
@@ -104,6 +116,10 @@ sub test () {
IkiWiki::check_canedit($file, $cgi, $session);
next;
}
+ else {
+ use Data::Dumper;
+ die "fall through test_changes add: " . Data::Dumper::Dumper($change);
+ }
}
}
elsif ($change->{action} eq 'remove') {
@@ -125,11 +141,9 @@ sub test () {
else {
error "unknown action ".$change->{action};
}
-
+
error sprintf(gettext("you are not allowed to change %s"), $file);
}
-
- exit 0;
}
1