package IkiWiki;
my %toping;
-my @processing_inline;
sub yesno ($) { #{{{
my $val=shift;
sub preprocess_inline (@) { #{{{
my %params=@_;
- # Avoid nested inlines, to avoid loops etc.
- return "" if grep { $_ eq $params{page} } @processing_inline;
- push @processing_inline, $params{page};
-
if (! exists $params{pages}) {
return "";
}
$toping{$params{page}}=1 unless $config{rebuild};
}
- pop @processing_inline;
return $ret;
} #}}}
return @ret;
} #}}}
+my @preprocessing;
sub preprocess ($$$) { #{{{
my $page=shift; # the page the data comes from
my $destpage=shift; # the page the data will appear in (different for inline)
if (length $escape) {
return "[[$command $params]]";
}
+ elsif (grep { $_ eq $page } @preprocessing) {
+ # Avoid loops of preprocessed pages preprocessing
+ # other pages that preprocess them, etc.
+ return "[[$command would cause preprocessing loop]]";
+ }
elsif (exists $hooks{preprocess}{$command}) {
# Note: preserve order of params, some plugins may
# consider it significant.
push @params, $val, '';
}
}
- return $hooks{preprocess}{$command}{call}->(
+ push @preprocessing, $page;
+ my $ret=$hooks{preprocess}{$command}{call}->(
@params,
page => $page,
destpage => $destpage,
);
+ pop @preprocessing;
+ return $ret;
}
else {
return "[[$command not processed]]";
* Use DESTDIR and not PREFIX to specify installation prefix for packaging.
* Support running "perl Makefile.PL PREFIX=foo" to build ikiwiki to run
from a different directory.
+ * Generalised preprocesser loop protection code.
- -- Joey Hess <joeyh@debian.org> Thu, 24 Aug 2006 21:28:45 -0400
+ -- Joey Hess <joeyh@debian.org> Fri, 25 Aug 2006 14:48:36 -0400
ikiwiki (1.21) unstable; urgency=low