Motivation
A preferences variable may refer to itself by accident as follows, which causes a loop.
* Set FOO = %FOO% bar
In many cases, this is not so harmful.
It causes a loop detected by TWiki and the loop is stopped.
However, if the preferences variable contains %INCLUDE{...}% as follows, it has a magnifying effect.
* Set FOO = %FOO% %INCLUDE{"http://server/path"}%
Specifically, http://server/path ends up being access 16 times or so per %FOO% on the page.
This should not be the end of the world.
But what if a heavy database query is magnified by multiple references of %FOO% on the page?
This may cause a very heavy load to an external resource.
Description and Documentation
There is no comprehensive way to detect and avoid recursion.
But an obvious ones like mentioned above can be easily detected and avoided.
It's a matter of enhancing TWiki::Prefs::PrefsCache::insert() as follows.
When a self-reference is detected, it will be escaped by inserting <nop> between % and the variable name.
Examples
The following line will end up setting "%<nop>FOO% bar" rather than "%FOO% bar" to FOO.
* Set FOO = %FOO% bar
Impact
Implementation
--
Contributors:
Hideyo Imazu - 2014-10-02
Discussion
Sensible, no-brainer fix.
--
Peter Thoeny - 2014-10-02
Accepted by release meeting at
KampalaReleaseMeeting2014x10x02
--
Peter Thoeny - 2014-10-04