* Generalised preprocesser loop protection code.
authorjoey <joey@0fa5a96a-9a0e-0410-b3b2-a0fd24251071>
Fri, 25 Aug 2006 19:06:37 +0000 (19:06 +0000)
committerjoey <joey@0fa5a96a-9a0e-0410-b3b2-a0fd24251071>
Fri, 25 Aug 2006 19:06:37 +0000 (19:06 +0000)
IkiWiki/Plugin/inline.pm
IkiWiki/Render.pm
debian/changelog

index c712f7bb434b80135b1d4742e3d4451de3f6163d..e7ec238ed96de84405327cbb03f92e4a6ed06f0c 100644 (file)
@@ -22,7 +22,6 @@ sub import { #{{{
 package IkiWiki;
 
 my %toping;
-my @processing_inline;
 
 sub yesno ($) { #{{{
        my $val=shift;
@@ -32,10 +31,6 @@ sub yesno ($) { #{{{
 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 "";
        }
@@ -133,7 +128,6 @@ sub preprocess_inline (@) { #{{{
                $toping{$params{page}}=1 unless $config{rebuild};
        }
        
-       pop @processing_inline;
        return $ret;
 } #}}}
 
index f386697287a0d341e74881867162cbd20acc017b..8e998e8b2fdfd248ef118fdcf3b3cf0e8262891b 100644 (file)
@@ -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]]";
index 0672428b1ada52c8efc9d034839970dd9790ba43..875d4f9a966897bea2050a314e14f41df89322fb 100644 (file)
@@ -30,8 +30,9 @@ ikiwiki (1.22) UNRELEASED; urgency=low
   * 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