]> sipb.mit.edu Git - ikiwiki.git/blobdiff - IkiWiki.pm
Receive: avoid hiding check_canedit error messages
[ikiwiki.git] / IkiWiki.pm
index df8abe2c2711281c220a604aa0ddca09ec915a02..d114c9a69d760194e05c788e36a74d4c8ab3c144 100644 (file)
@@ -1455,11 +1455,12 @@ sub filter ($$$) {
        return $content;
 }
 
-sub check_canedit ($$$;$) {
+sub check_canedit ($$$;$$) {
        my $page=shift;
        my $q=shift;
        my $session=shift;
        my $nonfatal=shift;
+       my $nosubs=shift;
        
        my $canedit;
        run_hooks(canedit => sub {
@@ -1470,6 +1471,7 @@ sub check_canedit ($$$;$) {
                                $canedit=1;
                        }
                        elsif (ref $ret eq 'CODE') {
+                               error(sprintf(gettext("you are not allowed to change %s"), $page)) if $nosubs && ! $nonfatal;
                                $ret->() unless $nonfatal;
                                $canedit=0;
                        }
@@ -2402,10 +2404,16 @@ sub derel ($$) {
        my $path=shift;
        my $from=shift;
 
-       if ($path =~ m!^\./!) {
-               $from=~s#/?[^/]+$## if defined $from;
-               $path=~s#^\./##;
-               $path="$from/$path" if defined $from && length $from;
+       if ($path =~ m!^\.(/|$)!) {
+               if ($1) {
+                       $from=~s#/?[^/]+$## if defined $from;
+                       $path=~s#^\./##;
+                       $path="$from/$path" if defined $from && length $from;
+               }
+               else {
+                       $path = $from;
+                       $path = "" unless defined $path;
+               }
        }
 
        return $path;