]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/blobdiff - IkiWiki/Render.pm
move influence tests to pagespec_match_list.t
[git.ikiwiki.info.git] / IkiWiki / Render.pm
index 8f9cbf673e481b9e1a291f6b0d58673f895d5917..0fe20c64f3a0939d7dde93107e7b0285e883e2a2 100644 (file)
@@ -285,24 +285,26 @@ sub find_src_files () {
        find({
                no_chdir => 1,
                wanted => sub {
-                       $_=decode_utf8($_);
-                       if (file_pruned($_, $config{srcdir})) {
+                       my $file=decode_utf8($_);
+                       $file=~s/^\Q$config{srcdir}\E\/?//;
+                       my $page = pagename($file);
+                       if (! exists $pagesources{$page} &&
+                           file_pruned($file)) {
                                $File::Find::prune=1;
+                               return;
                        }
-                       elsif (! -l $_ && ! -d _) {
-                               my ($f)=/$config{wiki_file_regexp}/; # untaint
-                               if (! defined $f) {
-                                       warn(sprintf(gettext("skipping bad filename %s"), $_)."\n");
-                               }
-                               else {
-                                       $f=~s/^\Q$config{srcdir}\E\/?//;
-                                       push @files, $f;
-                                       my $page = pagename($f);
-                                       if ($pages{$page}) {
-                                               debug(sprintf(gettext("%s has multiple possible source pages"), $page));
-                                       }
-                                       $pages{$page}=1;
+                       return if -l $_ || -d _ || ! length $file;
+
+                       my ($f) = $file =~ /$config{wiki_file_regexp}/; # untaint
+                       if (! defined $f) {
+                               warn(sprintf(gettext("skipping bad filename %s"), $file)."\n");
+                       }
+                       else {
+                               push @files, $f;
+                               if ($pages{$page}) {
+                                       debug(sprintf(gettext("%s has multiple possible source pages"), $page));
                                }
+                               $pages{$page}=1;
                        }
                },
        }, $config{srcdir});
@@ -310,27 +312,28 @@ sub find_src_files () {
                find({
                        no_chdir => 1,
                        wanted => sub {
-                               $_=decode_utf8($_);
-                               if (file_pruned($_, $dir)) {
+                               my $file=decode_utf8($_);
+                               $file=~s/^\Q$dir\E\/?//;
+                               my $page=pagename($file);
+                               if (! exists $pagesources{$page} &&
+                                   file_pruned($file)) {
                                        $File::Find::prune=1;
+                                       return;
                                }
-                               elsif (! -l $_ && ! -d _) {
-                                       my ($f)=/$config{wiki_file_regexp}/; # untaint
-                                       if (! defined $f) {
-                                               warn(sprintf(gettext("skipping bad filename %s"), $_)."\n");
-                                       }
-                                       else {
-                                               $f=~s/^\Q$dir\E\/?//;
-                                               # avoid underlaydir
-                                               # override attacks; see
-                                               # security.mdwn
-                                               if (! -l "$config{srcdir}/$f" && 
-                                                   ! -e _) {
-                                                       my $page=pagename($f);
-                                                       if (! $pages{$page}) {
-                                                               push @files, $f;
-                                                               $pages{$page}=1;
-                                                       }
+                               return if -l $_ || -d _ || ! length $file;
+
+                               my ($f) = $file =~ /$config{wiki_file_regexp}/; # untaint
+                               if (! defined $f) {
+                                       warn(sprintf(gettext("skipping bad filename %s"), $file)."\n");
+                               }
+                               else {
+                                       # avoid underlaydir override
+                                       # attacks; see security.mdwn
+                                       if (! -l "$config{srcdir}/$f" && 
+                                           ! -e _) {
+                                               if (! $pages{$page}) {
+                                                       push @files, $f;
+                                                       $pages{$page}=1;
                                                }
                                        }
                                }
@@ -494,7 +497,7 @@ sub calculate_changed_links ($$$) {
                                my $target=bestlink($page, $l);
                                if (! exists $oldlink_targets->{$page}{$l} ||
                                    $target ne $oldlink_targets->{$page}{$l}) {
-                                       $backlinkchanged{$l}=1;
+                                       $backlinkchanged{$target}=1;
                                        $linkchangers{lc($page)}=1;
                                }
                                delete $oldlink_targets->{$page}{$l};
@@ -502,7 +505,7 @@ sub calculate_changed_links ($$$) {
                }
                if (exists $oldlink_targets->{$page} &&
                    %{$oldlink_targets->{$page}}) {
-                       foreach my $target (keys %{$oldlink_targets->{$page}}) {
+                       foreach my $target (values %{$oldlink_targets->{$page}}) {
                                $backlinkchanged{$target}=1;
                        }
                        $linkchangers{lc($page)}=1;
@@ -557,7 +560,7 @@ sub render_dependent ($$$$$$$) {
                                my $in=sub {
                                        my $list=shift;
                                        my $type=shift;
-                                       foreach my $file ($list) {
+                                       foreach my $file (@$list) {
                                                next if $file eq $f;
                                                my $page=pagename($file);
                                                if ($sub->($page, location => $p)) {