Skip to content

Released version 3.1.8

Latest

Choose a tag to compare

@dg dg released this 17 Nov 17:52

✨ New Features

  • Extension::getAttributeContentTypes() – tell Latte that your custom attributes hold JavaScript, CSS or HTML, and it escapes them exactly like onclick, style or srcdoc. Map names or prefixes, such as 'x-on:*' => ContentType::JavaScript for Alpine or 'data-tippy-content' => ContentType::Html for Tippy, and it works in static values, name={$x} and n:attr alike (#426)

⚠️ Behavior Changes

  • srcdoc – trusted HTML passed as a plain string is now displayed as text (see Security). Wrap it in Latte\Runtime\Html or use |noescape; an Html object now keeps its tags. With migration warnings on, Latte reports every value whose output changes (#425)
  • A null URL attribute is omitted like any other attribute: <a href={$url}> with null renders no href instead of href="". Migration warnings report it (#428)
  • Deprecated: a positional argument after a named one in {include}, {embed}, {extends}, {layout}, {import} and {sandbox}, as PHP forbids such a call; it will be an error in the next minor version

🔒 Security

  • The srcdoc attribute is escaped twice, as the browser decodes it twice, so <iframe srcdoc="<p>{$x}</p>"> cannot smuggle in a <script> (#425)
  • Vue, petite-vue and AngularJS can no longer find a {{ formed by adjacent outputs such as {$a}{$b}, or printed from a variable inside <script type="text/template">

🐛 Bug Fixes

  • Braces in <textarea> and <title> are printed as they are, so a value like {{ }} passes through a form unchanged (#409)
  • Blocks and includes in XML templates have the XML content type, so included text is converted by XML rules and including XML into XML works; mixing XML and HTML still works with a deprecation (#433)
  • |number and |bytes with a locale round a half away from zero, the same as without one, and are much faster on repeated calls (#427)
  • Whitespace: the newline after an indented end tag such as </ul>{/if} is kept, and the indentation of a line like {/block}</p> stays inside the block (#344)
  • Loading the same template from concurrent Swoole coroutines or fibers works (#404)

Thanks to @vrana for the attribute content types and the srcdoc, URL and XML escaping (#425, #426, #428, #433), and to @vosikar and @zipper for #427 and #424.