зеркало из
1
0
Форкнуть 0
This commit is contained in:
Frederik Braun 2015-11-06 15:42:22 +01:00
Родитель 13a36c50fe
Коммит cf8039a19a
1 изменённых файлов: 13 добавлений и 0 удалений

Просмотреть файл

@ -19,6 +19,19 @@ module.exports = function (context) {
var VALID_ESCAPERS = ["Sanitizer.escapeHTML", "escapeHTML"];
var VALID_UNWRAPPERS = ["Sanitizer.unwrapSafeHTML", "unwrapSafeHTML"];
/**
* Returns true if the expression contains allowed syntax, otherwise false.
* For Template Strings with interpolation (e.g. |`${foo}`|) and
* Binary Expressions (e.g. |foo+bar|), the function will look into the expression
* recursively.
* For testing and development, I recommend looking at example code and its syntax tree.
* Using the Esprima Demo, for example: http://esprima.org/demo/parse.html
*
* @param {Object} expression Checks whether this node is an allowed expression.
* @param {Object} parent Parent node of the expression node (first param)
* @returns {boolean}
*/
function allowedExpression(expression, parent) {
if (typeof parent === "undefined") {
throw new Error("allowedExpressions() expects two parameters. Only one given.");