- find({
- no_chdir => 1,
- wanted => sub {
- my ($file, $page) = verify_src_file(decode_utf8($_), $config{srcdir});
- if (defined $file) {
- push @files, $file;
- if ($pages{$page}) {
- debug(sprintf(gettext("%s has multiple possible source pages"), $page));
+
+ my ($page, $dir, $underlay);
+ my $helper=sub {
+ my $file=decode_utf8($_);
+
+ return if -l $file || -d _;
+ $file=~s/^\Q$dir\E\/?//;
+ return if ! length $file;
+ $page = pagename($file);
+ if (! exists $pagesources{$page} &&
+ file_pruned($file)) {
+ $File::Find::prune=1;
+ return;
+ }
+
+ my ($f) = $file =~ /$config{wiki_file_regexp}/; # untaint
+ if (! defined $f) {
+ warn(sprintf(gettext("skipping bad filename %s"), $file)."\n");
+ }
+
+ if ($underlay) {
+ # avoid underlaydir override attacks; see security.mdwn
+ if (! -l "$config{srcdir}/$f" && ! -e _) {
+ if (! $pages{$page}) {
+ push @files, $f;
+ $pages{$page}=1;