diff options
Diffstat (limited to 'IkiWiki')
-rw-r--r-- | IkiWiki/CGI.pm | 2 | ||||
-rw-r--r-- | IkiWiki/Rcs/SVN.pm | 1 | ||||
-rw-r--r-- | IkiWiki/Render.pm | 39 |
3 files changed, 33 insertions, 9 deletions
diff --git a/IkiWiki/CGI.pm b/IkiWiki/CGI.pm index 67bce6795..6fd1f6506 100644 --- a/IkiWiki/CGI.pm +++ b/IkiWiki/CGI.pm @@ -403,7 +403,7 @@ sub cgi_editpage ($$) { #{{{ ! length $form->field('content')) { my $content=""; if (exists $pagesources{lc($page)}) { - $content=readfile("$config{srcdir}/$pagesources{lc($page)}"); + $content=readfile(srcfile($pagesources{lc($page)})); $content=~s/\n/\r\n/g; } $form->field(name => "content", value => $content, diff --git a/IkiWiki/Rcs/SVN.pm b/IkiWiki/Rcs/SVN.pm index 083b869df..02fc3ed31 100644 --- a/IkiWiki/Rcs/SVN.pm +++ b/IkiWiki/Rcs/SVN.pm @@ -171,6 +171,7 @@ sub rcs_getctime () { #{{{ eval q{use Date::Parse}; foreach my $page (keys %pagectime) { my $file="$config{srcdir}/$pagesources{$page}"; + next unless -e $file; my $child = open(SVNLOG, "-|"); if (! $child) { exec("svn", "log", $file) || error("svn log $file failed to run"); diff --git a/IkiWiki/Render.pm b/IkiWiki/Render.pm index 7d1e8ee53..3d827d341 100644 --- a/IkiWiki/Render.pm +++ b/IkiWiki/Render.pm @@ -139,7 +139,7 @@ sub get_inline_content ($$) { #{{{ my $file=$pagesources{$page}; my $type=pagetype($file); if ($type ne 'unknown') { - return htmlize($type, linkify(readfile("$config{srcdir}/$file"), $parentpage)); + return htmlize($type, linkify(readfile(srcfile($file)), $parentpage)); } else { return ""; @@ -337,7 +337,8 @@ sub render ($) { #{{{ my $file=shift; my $type=pagetype($file); - my $content=readfile("$config{srcdir}/$file"); + my $srcfile=srcfile($file); + my $content=readfile($srcfile); if ($type ne 'unknown') { my $page=pagename($file); @@ -349,7 +350,7 @@ sub render ($) { #{{{ check_overwrite("$config{destdir}/".htmlpage($page), $page); writefile("$config{destdir}/".htmlpage($page), - genpage($content, $page, mtime("$config{srcdir}/$file"))); + genpage($content, $page, mtime($srcfile))); $oldpagemtime{$page}=time; $renderedfiles{$page}=htmlpage($page); @@ -358,7 +359,7 @@ sub render ($) { #{{{ # only supports listing one file per page. if ($config{rss} && exists $inlinepages{$page}) { writefile("$config{destdir}/".rsspage($page), - genrss($content, $page, mtime("$config{srcdir}/$file"))); + genrss($content, $page, mtime($srcfile))); } } else { @@ -389,9 +390,7 @@ sub refresh () { #{{{ no_chdir => 1, wanted => sub { if (/$config{wiki_file_prune_regexp}/) { - no warnings 'once'; $File::Find::prune=1; - use warnings "all"; } elsif (! -d $_ && ! -l $_) { my ($f)=/$config{wiki_file_regexp}/; # untaint @@ -406,6 +405,30 @@ sub refresh () { #{{{ } }, }, $config{srcdir}); + find({ + no_chdir => 1, + wanted => sub { + if (/$config{wiki_file_prune_regexp}/) { + $File::Find::prune=1; + } + elsif (! -d $_ && ! -l $_) { + my ($f)=/$config{wiki_file_regexp}/; # untaint + if (! defined $f) { + warn("skipping bad filename $_\n"); + } + else { + # Don't add files that are in the + # srcdir. + $f=~s/^\Q$config{underlaydir}\E\/?//; + if (! -e "$config{srcdir}/$f" && + ! -l "$config{srcdir}/$f") { + push @files, $f; + $exists{pagename($f)}=1; + } + } + } + }, + }, $config{underlaydir}); my %rendered; @@ -418,7 +441,7 @@ sub refresh () { #{{{ push @add, $file; $links{$page}=[]; $pagesources{$page}=$file; - $pagectime{$page}=mtime("$config{srcdir}/$file") + $pagectime{$page}=mtime(srcfile($file)) unless exists $pagectime{$page}; } } @@ -439,7 +462,7 @@ sub refresh () { #{{{ my $page=pagename($file); if (! exists $oldpagemtime{$page} || - mtime("$config{srcdir}/$file") > $oldpagemtime{$page}) { + mtime(srcfile($file)) > $oldpagemtime{$page}) { debug("rendering changed file $file"); render($file); $rendered{$file}=1; |