| latte | by dg | Released version 3.1.8 | | | |
| latte | by dg | updated upgrading.md | | | |
| latte | by dg | added security.md 13dc022f-b2cc-4df9-a89a-9e83e48df17d | | | |
| latte | by dg | TemplateParser: fixed indentation of a closing tag leaking out of its content [Closes #344] On a line like ' {/block}</p>' the indentation stayed in TemplateParser::$lastIndentation across the closing Latte tag, and extractIndentation() then moved it in front of the HTML tag, i.e. out of the block. {block|strip}, |trim and {spaceless} left it in the output, a false {if} printed it and {capture} lost it. | | | |
| latte | by vrana | Escaper: blocks and includes in XML have the XML content type (#433) The XML escaper shares the HTML states and export() named them html, html/attr, ..., so a block in XML had the type html, an include into XML was converted as into HTML (text kept control characters, which are invalid in XML, and got the empty comment separating braces) and including XML into XML failed as incompatible. The Convertors entries for xml and xml/attr, and the xml types accepted by |stripHtml and |stripTags, were never reached. export() now names them xml, xml/attr, xml/comment. Text, JS and CSS are converted into XML by the XML escapers. Filters see the XML type, so |spaceless minifies a block as XML; a contextual filter that compares the type with ContentType::Html no longer matches in an XML template. XML and HTML converted into each other like HTML into HTML. That keeps working, with E_USER_DEPRECATED, also when a block of an HTML template overrides a block of an XML layout. Including an XML template into HTML, which used to throw, now works with the same deprecation. | | | |
| latte | by dg | HtmlHelpers: classifyAttributeType() caches the result n:attr classifies every attribute name at runtime, and matching it against the table of attribute content types made that 4 times slower with the built-in table (96 -> 377 ns per name) and 9 times slower with a table of 11 entries. The result is now cached per name and holds for the table it was computed with, which brings n:attr back to its previous speed. The cache is limited to 1000 names, since names in n:attr may come from data. | | | |
| latte | by vrana | Extension: added getAttributeContentTypes() for escaping custom attributes as JS, CSS or HTML (#426) An extension can map attribute names, or prefixes ending with *, to ContentType::JavaScript, Css or Html, e.g. 'x-on:*' => JavaScript or Tippy's 'data-tippy-content' => Html. A registered attribute is escaped exactly like on*, style or srcdoc, which are the default entries of the same table (HtmlHelpers::AttributeContentTypes): static values via the Escaper subType, dynamic attributes (name={$x}) and n:attr via classifyAttributeType(). n:attr receives the table as a compiled argument only when some attribute is registered. Built-in entries can't be overridden (on*, style, srcdoc and prefixes like s* are rejected). The table is part of the configuration signature, so extensions don't have to include it in getCacheKey(). | | | |
| latte | by dg | Escaper: <textarea> and <title> keep braces intact The browser does not parse their content as HTML, so the empty comment separating braces was displayed and corrupted the value, e.g. a {{ }} in a submitted form (#409). The content is printed by HtmlHelpers::escapeRcData() without touching braces; convertRcDataToHtml() separates them when a block defined there is included into ordinary text. | | | |
| latte | by dg | Escaper: content of <textarea> and <title> has the subType rcdata Their content is text that the browser does not parse as HTML. A block placed there has the content type html/rcdata, which contextual filters now see instead of html; |stripHtml and |stripTags accept it. It is escaped and converted the same way as HTML text. | | | |
| latte | by dg | HtmlHelpers: {{ cannot form from adjacent outputs [security] Vue, petite-vue and AngularJS read the DOM after the browser has decoded entities, so the { that escapeText() used for a single brace did not protect anything: {$a}{$b} with '{' and '{7*7}}' produced a live {{ }}, and so did '{{{' because strtr() replaced only non-overlapping pairs. A brace followed by another one or ending the string, and a leading one, is now separated by an empty comment; a brace in the middle stays as it is. convertAttrToHtml() escapes as HTML text, so {{ cannot form when a block from an attribute is included into text. escapeRawHtml() for <script type="text/template"> did not touch braces at all, so Vue evaluated {{ }} from a variable there. Latte does not parse the template in such a script, so a value may land in an attribute, where a comment would corrupt values like data-x="{$json}"; braces are entities there, which Vue 3 respects. | | | |
| latte | by vrana | Passes: null in URL attribute drops it like in other attributes (BC break) (#428) Since 3.1, a null value of an attribute means the attribute is omitted. URL attributes were an exception: the checkUrls pass appends |checkUrl, which converts null to '', so <a href={$url}> with null rendered href="". That makes the element a link to the current page. The pass now appends the filter as nullsafe ?|checkUrl, so null skips it and the attribute is dropped. With migration warnings, the change is reported like for other attributes. | | | |
| latte | by vrana | HtmlHelpers: srcdoc triggers a migration warning for a value previously rendered as HTML (#425) With Feature::MigrationWarnings, a plain srcdoc value that renders as a different document now than before (it contains a tag or a character reference, also one that browsers decode without a semicolon) triggers a warning suggesting to wrap trusted HTML in Latte\Runtime\Html. Text such as 'a & b' or 'a < b' renders the same document as before and stays quiet; so does an Html object, whose tags were stripped before and are kept now. |accept silences it. It covers dynamic attributes (srcdoc={$x}, srcdoc="{$x}") and n:attr. A mixed value like srcdoc="<p>{$x}</p>" is escaped by code the Escaper emits, which has no access to feature flags, so it does not warn. | | | |
| latte | by vrana | Escaper: srcdoc attribute is escaped as an HTML document [security] (BC break) (#425) The value of srcdoc is an HTML document: the browser attribute-decodes it and then parses the result as HTML. Latte escaped it like any other attribute, so <iframe srcdoc="<p>{$x}</p>"> with $x = '<script>...</script>' rendered <script>, which decodes to a live <script>. An iframe without sandbox shares the parent's origin, so this was an XSS. srcdoc now gets its own html/attr/html context: a value is escaped twice as an attribute value (HtmlHelpers::escapeHtmlAttr). Latte does not parse the document, so the value may land in its text as well as in one of its attributes, as in <iframe srcdoc="<p title="{$x}">">, where an unescaped quote would let it add an event handler. This covers the static attribute, the dynamic attribute srcdoc={$x}, n:attr and blocks or templates included into srcdoc. An Html object is encoded only once, so trusted markup keeps its tags; previously they were stripped. BC break: trusted HTML passed as a plain string is now displayed as text. Wrap it in Latte\Runtime\Html (or use |noescape). | | | |
| latte | by dg | Node: child lists are walked, not returned removeNulls() ran after the loop, so a traversal cut short by StopTraversal or an exception left the removed item as a null hole in the list - the generator is discarded and code past its last yield never runs. walk() prunes in finally instead, and accepts a nullable list, so the if() around such a foreach can go. Helpers::removeNulls() has no caller left and is deprecated in favour of walk(). | | | |
| latte | by dg | Nodes: positional argument after a named one is deprecated In {include}, {embed}, {extends}, {layout}, {import} and {sandbox} the arguments are bound to parameters by position and by name, so in {include block, name: $a, $b} the positional $b takes position 0 and overrides $name. PHP forbids such a call; Latte now triggers E_USER_DEPRECATED and will throw in the next minor version. These tags parse their arguments with TagParser::parseCallArguments(). Arrays of n:attr and n:class are not affected. | | | |
| latte | by dg | Filters: number() and bytes() reuse the NumberFormatter Creating a formatter costs about 7 µs, formatting with an existing one 0.3 µs. The rounding mode is now set in a single place. | | | |
| latte | by vosikar | Filters: number() and bytes() with locale round half up like without locale (#427) NumberFormatter's default is half-even. | | | |
| latte | by zipper | readme: added Latte+ to the list of PhpStorm plugins (#424) | | | |
| latte | by dg | Cache: skips including a template whose class is already declared A coroutine (Swoole) or a fiber can pass the class_exists() check in Engine::loadTemplate() and then wait for the cache lock while another one declares the class. After getting the lock it included the file again and failed with "Cannot redeclare class". | | | |
| latte | by dg | TemplateParserHtml: fixed newline lost after indented end tag extractIndentation() moved the indentation into the element but left TemplateParser::$lastIndentation set, so a line like ' </ul>{/if}' was taken for a line holding only a Latte tag and lost its newline. | | | |
| database | by dg | removed legacy services names (BC break) | | | |
| database | by dg | Selection: removed create*() methods | | | |
| database | by dg | použití třídy Database | | | |
| database | by dg | Explorer: added autoCommit() | | | |
| database | by dg | transaction via savepoints WIP | | | |
| database | by dg | DatabaseExtension: added 'username' as alias for 'user' | | | |
| database | by dg | strict convention WIP - na umeligenci byl problem, že $event->id chapal jako 'courseId' | | | |
| database | by dg | ActiveRow::_get() does not return a reference | | | |
| database | by dg | added Explorer::createFromDsn() & createFromParameters() | | | |
| database | by dg | Result: uses yield for iteration | | | |
| database | by dg | Selection: uses yield for iteration | | | |
| database | by dg | Engine::delimite() -> delimit() (BC break) | | | |