diff options
author | joey <joey@0fa5a96a-9a0e-0410-b3b2-a0fd24251071> | 2006-08-25 19:06:37 +0000 |
---|---|---|
committer | joey <joey@0fa5a96a-9a0e-0410-b3b2-a0fd24251071> | 2006-08-25 19:06:37 +0000 |
commit | 6fc3b624f209f71335bed9947eda956e7d118458 (patch) | |
tree | e1b271efff85a7fb5ce627e3fdb23032088def7c /IkiWiki/Render.pm | |
parent | f4d99ac1ca03121255e545df89e7d841a02cc0bf (diff) | |
download | ikiwiki-6fc3b624f209f71335bed9947eda956e7d118458.tar ikiwiki-6fc3b624f209f71335bed9947eda956e7d118458.tar.gz |
* Generalised preprocesser loop protection code.
Diffstat (limited to 'IkiWiki/Render.pm')
-rw-r--r-- | IkiWiki/Render.pm | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/IkiWiki/Render.pm b/IkiWiki/Render.pm index f38669728..8e998e8b2 100644 --- a/IkiWiki/Render.pm +++ b/IkiWiki/Render.pm @@ -84,6 +84,7 @@ sub parentlinks ($) { #{{{ 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) @@ -96,6 +97,11 @@ sub preprocess ($$$) { #{{{ 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. @@ -123,11 +129,14 @@ sub preprocess ($$$) { #{{{ 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]]"; |