NOTE: If you are a developer, please use a private wiki based on foswiki/trunk on a daily base ...or use
trunk.foswiki.org to view this page for some minimal testing.
Use
Item9693 for docu changes for 1.2 and 2.0.
Item10807: Prevent recursion in template expansion
| Priority: |
CurrentState: |
AppliesTo: |
Component: |
WaitingFor: |
| Urgent |
Closed |
Engine |
|
|
--
ArthurClemens - 28 May 2011
Re-opening as a release blocker, as this has caused a problem.
The expansion limit is set to 999; however it is never reset, so if any template is instantiated 1000 times (without recursion) you will get an exception.
For example, add
%ICON{"alert"}% to a topic 1001 times. It will bomb.
Patch (trunk) follows:
Index: Templates.pm
===================================================================
--- Templates.pm (revision 13382)
+++ Templates.pm (working copy)
@@ -192,6 +192,8 @@
$val =~ s/%TMPL:P{(.*?)}%/$this->expandTemplate($1)/ge;
}
+ $this->{expansionRecursions}->{$template} -= 1;
+
return $val;
}
--
CrawfordCurrie - 14 Dec 2011
That is certainly an improvement. Tested on release branch.
Test template:
%TMPL:INCLUDE{"view"}%
%TMPL:P{"loop"}%
%TMPL:DEF{"loop"}%
loop
%TMPL:P{"loop"}%
%TMPL:END%
--
ArthurClemens - 14 Dec 2011
Added a small improvement to the testcase; the 'x' operator allows you to repeat a string many times.
--
CrawfordCurrie - 15 Dec 2011