Skip to content

Commit

Permalink
Policy::createSafePolicy() added new filters and tags
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Feb 22, 2021
1 parent c4045eb commit 35d4a0d
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/Latte/Sandbox/SecurityPolicy.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,23 @@ public static function createSafePolicy(): self
// php (but 'do' is allowed), sandbox, snippet, snippetArea, templatePrint, varPrint, embed
$policy->allowMacros([
'_', '=', 'attr', 'block', 'breakIf', 'capture', 'case', 'class', 'continueIf', 'default',
'define', 'do', 'else', 'elseif', 'elseifset', 'first', 'for', 'foreach', 'if', 'ifchanged', 'ifcontent',
'ifset', 'l', 'last', 'r', 'rollback', 'sep', 'skipIf', 'spaceless', 'switch', 'templateType', 'try', 'var', 'varType', 'while',
'define', 'do', 'else', 'elseif', 'elseifset', 'first', 'for', 'foreach', 'if', 'ifchanged',
'ifcontent', 'iterateWhile', 'ifset', 'l', 'last', 'r', 'rollback', 'sep', 'skipIf', 'spaceless',
'switch', 'templateType', 'try', 'var', 'varType', 'while',
]);

// does not include: dataStream, noEscape, noCheck
$policy->allowFilters([
'batch', 'breakLines', 'bytes', 'capitalize', 'clamp', 'date', 'escapeCss', 'escapeHtml', 'escapeHtmlComment', 'escapeICal',
'escapeJs', 'escapeUrl', 'escapeXml', 'firstUpper', 'checkUrl', 'implode', 'indent', 'length', 'lower', 'number',
'padLeft', 'padRight', 'repeat', 'replace', 'replaceRe', 'reverse', 'sort', 'strip', 'stripHtml', 'stripTags', 'substr',
'batch', 'breakLines', 'bytes', 'capitalize', 'ceil', 'clamp', 'date', 'escapeCss', 'escapeHtml',
'escapeHtmlComment', 'escapeICal', 'escapeJs', 'escapeUrl', 'escapeXml', 'explode', 'first',
'firstUpper', 'floor', 'checkUrl', 'implode', 'indent', 'join', 'last', 'length', 'lower',
'number', 'padLeft', 'padRight', 'query', 'random', 'repeat', 'replace', 'replaceRe', 'reverse',
'round', 'slice', 'sort', 'spaceless', 'split', 'strip', 'stripHtml', 'stripTags', 'substr',
'trim', 'truncate', 'upper', 'webalize',
]);

$policy->allowFunctions(['clamp', 'divisibleBy', 'even', 'first', 'last', 'odd', 'slice']);

$policy->allowMethods(Latte\Runtime\CachingIterator::class, self::ALL);
$policy->allowProperties(Latte\Runtime\CachingIterator::class, self::ALL);

Expand Down

0 comments on commit 35d4a0d

Please sign in to comment.