Repository navigation
This release closes several ways a sandboxed template could get around the security policy. Only applications that render templates of untrusted authors in the sandbox (setSandboxMode() or {sandbox}) are affected; for them the update is recommended.
🔒 Security
{iterateWhile}assigns the{foreach}target with the same policy check as{foreach}itself, so it can no longer write a property the policy does not allow{first},{last},{sep},{skipIf},{iterateWhile}and{else}of{foreach}call methods of an internal iterator, never of$iterator, which a template could overwrite with a host object- Arguments of
{include},{embed},{extends},{import}and{sandbox}cannot set internal$ʟ_*variables; a literal key is a compile error, an unpacked or computed one is refused at runtime - The
n:elsebranch ofn:ifcontentand the expression in the name of a dynamic{block}or{define}are checked by the sandbox like any other code |sortand|groupread the property named bybyorbyKeythrough the policy; allow the properties your templates sort or group by- createSafePolicy() no longer allows
|queryand|escapeJs, which serialize an object with all its public properties; allow them explicitly if your templates need them - A dynamic property name whose
__toString()returns a different value each time can no longer pass the check with one name and read another
💥 Breaking Changes
- A sandboxed template using
|queryor|escapeJsundercreateSafePolicy(), or sorting and grouping by a property the policy does not allow, now throwsSecurityViolationException(see Security) - For authors of custom tags:
TagParser::parseCallArguments(), added in 3.1.9, is replaced byparseArguments()followed byNodeHelpers::checkArgumentOrder($args)
🐛 Bug Fixes
- Deprecation notices raised while compiling a template name its file, not only the line (#436)
{foreach $items as $iterator}no longer breaks{first},{last},{sep}and{iterateWhile}inside the loop- A custom function in the name of a dynamic block (
{block blockName()}) is resolved - A template containing a null byte throws
CompileExceptioninstead ofValueError