X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/blobdiff_plain/7aa209f1ce882372590ff032a1a94ad2b977544d..f7d4904fee5fcc380196d9c6825676040270270f:/IkiWiki/Render.pm?ds=inline diff --git a/IkiWiki/Render.pm b/IkiWiki/Render.pm index f9fbc801f..740bb52b0 100644 --- a/IkiWiki/Render.pm +++ b/IkiWiki/Render.pm @@ -292,12 +292,16 @@ sub find_src_files () { eval q{use File::Find}; error($@) if $@; - my ($page, $dir, $underlay); + eval q{use Cwd}; + die $@ if $@; + my $origdir=getcwd(); + my $abssrcdir=Cwd::abs_path($config{srcdir}); + + my ($page, $underlay); my $helper=sub { my $file=decode_utf8($_); - return if -l $file || -d _; - $file=~s/^\Q$dir\E\/?//; + $file=~s/^\.\///; return if ! length $file; $page = pagename($file); if (! exists $pagesources{$page} && @@ -314,7 +318,7 @@ sub find_src_files () { if ($underlay) { # avoid underlaydir override attacks; see security.mdwn - if (! -l "$config{srcdir}/$f" && ! -e _) { + if (! -l "$abssrcdir/$f" && ! -e _) { if (! $pages{$page}) { push @files, $f; $pages{$page}=1; @@ -330,17 +334,23 @@ sub find_src_files () { } }; + chdir($config{srcdir}) || die "chdir: $!"; find({ no_chdir => 1, wanted => $helper, - }, $dir=$config{srcdir}); + }, '.'); + chdir($origdir) || die "chdir: $!"; + $underlay=1; foreach (@{$config{underlaydirs}}, $config{underlaydir}) { + chdir($_) || die "chdir: $!"; find({ no_chdir => 1, wanted => $helper, - }, $dir=$_); + }, '.'); + chdir($origdir) || die "chdir: $!"; }; + return \@files, \%pages; }