aboutsummaryrefslogtreecommitdiff
path: root/IkiWiki/Render.pm
diff options
context:
space:
mode:
authorJoey Hess <joey@kitenet.net>2010-04-17 12:50:23 -0400
committerJoey Hess <joey@kitenet.net>2010-04-17 12:50:23 -0400
commit54f600af14bf6dc067ffc30ec6f22d517001fe99 (patch)
treeddd20f6f03bc376700f8ebac24f360bf1fe3b269 /IkiWiki/Render.pm
parent7fcc0faf8367c5ae64a3ff06d0d74baa063c4dfc (diff)
parent981400177d68a279f485727be3f013e68f0bf691 (diff)
downloadikiwiki-54f600af14bf6dc067ffc30ec6f22d517001fe99.tar
ikiwiki-54f600af14bf6dc067ffc30ec6f22d517001fe99.tar.gz
Merge remote branch 'davrieb/autotag' into autotag
Conflicts: IkiWiki.pm IkiWiki/Plugin/tag.pm
Diffstat (limited to 'IkiWiki/Render.pm')
-rw-r--r--IkiWiki/Render.pm78
1 files changed, 45 insertions, 33 deletions
diff --git a/IkiWiki/Render.pm b/IkiWiki/Render.pm
index a6b0f0617..796af6af2 100644
--- a/IkiWiki/Render.pm
+++ b/IkiWiki/Render.pm
@@ -281,6 +281,27 @@ sub srcdir_check () {
}
+sub verify_src_file ($$) {
+ my $file=decode_utf8(shift);
+ my $dir=shift;
+
+ return if -l $file || -d _;
+ $file=~s/^\Q$dir\E\/?//;
+ return if ! length $file;
+ my $page = pagename($file);
+ if (! exists $pagesources{$page} &&
+ file_pruned($file)) {
+ $File::Find::prune=1;
+ return;
+ }
+
+ my ($file_untainted) = $file =~ /$config{wiki_file_regexp}/; # untaint
+ if (! defined $file_untainted) {
+ warn(sprintf(gettext("skipping bad filename %s"), $file)."\n");
+ }
+ return ($file_untainted, $page);
+}
+
sub find_src_files () {
my @files;
my %pages;
@@ -289,22 +310,9 @@ sub find_src_files () {
find({
no_chdir => 1,
wanted => sub {
- my $file=decode_utf8($_);
- $file=~s/^\Q$config{srcdir}\E\/?//;
- return if -l $_ || -d _ || ! length $file;
- my $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");
- }
- else {
- push @files, $f;
+ my ($file, $page) = verify_src_file($_, $config{srcdir});
+ if (defined $file) {
+ push @files, $file;
if ($pages{$page}) {
debug(sprintf(gettext("%s has multiple possible source pages"), $page));
}
@@ -316,27 +324,14 @@ sub find_src_files () {
find({
no_chdir => 1,
wanted => sub {
- my $file=decode_utf8($_);
- $file=~s/^\Q$dir\E\/?//;
- return if -l $_ || -d _ || ! length $file;
- my $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");
- }
- else {
+ my ($file, $page) = verify_src_file($_, $dir);
+ if (defined $file) {
# avoid underlaydir override
# attacks; see security.mdwn
- if (! -l "$config{srcdir}/$f" &&
+ if (! -l "$config{srcdir}/$file" &&
! -e _) {
if (! $pages{$page}) {
- push @files, $f;
+ push @files, $file;
$pages{$page}=1;
}
}
@@ -694,11 +689,28 @@ sub refresh () {
my ($changed, $internal_changed)=find_changed($files);
run_hooks(needsbuild => sub { shift->($changed) });
my $oldlink_targets=calculate_old_links($changed, $del);
+ %del_hash = map { $_ => 1 } @{$del};
foreach my $file (@$changed) {
scan($file);
}
+ while (my $autofile = shift @{[keys %autofiles]}) {
+ my $plugin=$autofiles{$autofile};
+ my $page=pagename($autofile);
+ if ($pages->{$page}) {
+ debug(sprintf(gettext("%s has multiple possible source pages"), $page));
+ }
+ $pages->{$page}=1;
+
+ push @{$files}, $autofile;
+ push @{$new}, $autofile if find_new_files([$autofile]);
+ push @{$changed}, $autofile if find_changed([$autofile]);
+
+ scan($autofile);
+ delete $autofiles{$autofile};
+ }
+
calculate_links();
remove_del(@$del, @$internal_del);