diff --git a/core/modules/filters.js b/core/modules/filters.js index 0cd0d2dbd..2c23ee297 100644 --- a/core/modules/filters.js +++ b/core/modules/filters.js @@ -12,6 +12,9 @@ Adds tiddler filtering methods to the $tw.Wiki object. /*global $tw: false */ "use strict"; +/* Maximum permitted filter recursion depth */ +var MAX_FILTER_DEPTH = 300; + /* Parses an operation (i.e. a run) within a filter string operators: Array of array of operator nodes into which results should be inserted @@ -341,7 +344,7 @@ exports.compileFilter = function(filterString) { } var results = new $tw.utils.LinkedList(); self.filterRecursionCount = (self.filterRecursionCount || 0) + 1; - if(self.filterRecursionCount < 300) { + if(self.filterRecursionCount < MAX_FILTER_DEPTH) { $tw.utils.each(operationFunctions,function(operationFunction) { operationFunction(results,source,widget); }); diff --git a/editions/test/tiddlers/tests/data/filters/Recursion.tid b/editions/test/tiddlers/tests/data/filters/Recursion.tid new file mode 100644 index 000000000..13d80e521 --- /dev/null +++ b/editions/test/tiddlers/tests/data/filters/Recursion.tid @@ -0,0 +1,15 @@ +title: Filters/Recursion +description: Filter recursion detection +type: text/vnd.tiddlywiki-multiple +tags: [[$:/tags/wiki-test-spec]] + +title: Output + +\whitespace trim +\define myfilter() [subfilter] + +<$text text={{{ [subfilter] }}}/> ++ +title: ExpectedResult + +

/**-- Excessive filter recursion --**/

\ No newline at end of file diff --git a/editions/test/tiddlers/tests/data/transclude/Recursion.tid b/editions/test/tiddlers/tests/data/transclude/Recursion.tid index 23ec97b13..d75e671eb 100644 --- a/editions/test/tiddlers/tests/data/transclude/Recursion.tid +++ b/editions/test/tiddlers/tests/data/transclude/Recursion.tid @@ -6,11 +6,7 @@ tags: [[$:/tags/wiki-test-spec]] title: Output \whitespace trim -\procedure recurse(a:0) -<$transclude $variable="recurse" a={{{ [add[1]] }}}/> -\end - -<> +<$transclude $tiddler="Output"/> + title: ExpectedResult diff --git a/editions/tw5.com/tiddlers/widgets/LetWidget.tid b/editions/tw5.com/tiddlers/widgets/LetWidget.tid index b66fed0fd..b27306cfb 100644 --- a/editions/tw5.com/tiddlers/widgets/LetWidget.tid +++ b/editions/tw5.com/tiddlers/widgets/LetWidget.tid @@ -1,6 +1,6 @@ title: LetWidget -created: 20220502144738010 -modified: 20220502144738010 +created: 20211028115900000 +modified: 20221001094658854 tags: Widgets caption: let @@ -13,12 +13,12 @@ caption: let The content of the <<.wid let>> widget is the scope for the value assigned to the variable. |!Attribute |!Description | -|//{any attributes}// |Each attribute name specifies a variable name. The attribute value is assigned to the variable | - -<<.from-version "5.3.0">> Previously, variable names were restricted to not start with a dollar sign. That restriction is no longer applied. +|//{attributes}// |Each attribute name specifies a variable name. The attribute value is assigned to the variable | Attributes are evaluated in the order they are written. Attributes with the same name are allowed. Each time a duplicate attribute is encountered, it will replace the existing value set by the earlier duplicate. +<<.note """<<.from-version "5.2.4">> There is no longer any restriction on using variable names that start with the $ character.""">> + ! Examples Consider a case where you need to set multiple variables, where some depend on the evaluation of others.