| latte | by dg | sandbox: objects are encoded to JSON as far as the policy allows (BC break) json_encode() prints every public property of an object and calls jsonSerialize(), past the policy: in <script>, in JavaScript attributes and templates, and for an array in data-* attributes, |json and n:attr. Encoding now reads only what the policy allows to read: every public property must be allowed like {$obj->prop}, a JsonSerializable must be allowed jsonSerialize(), recursively through arrays, property values and what jsonSerialize() returns. HTML and trusted content is still printed as a string. The check is printed by variants of ModifierNode, ExpressionAttributeNode and of the arguments of n:attr, which the sandbox pass puts in place of the nodes, so the compiler knows nothing about the sandbox. It needs two neutral seams: Escaper::encodesJson() and ExpressionAttributeNode::printValue(). | | | |
| latte | by dg | Filters: checkUrl() leaves a value that is not a string to the attribute formatter checkUrl() cast every value to string, so href={$x} never showed the formatter anything else: true was printed as href="1", false as href="", an array as href="Array" with a PHP warning and an object without __toString() ended with an Error. n:attr checks only a string or Stringable and passes the rest on; the filter does the same now, and both forms report 'Invalid value for attribute'. | | | |
| latte | by dg | CoreExtension: filters |escapeHtml, |escapeJs etc. convert trusted content like a print A filter |escapeX turns a value into content type X, so {$text|escapeHtml} takes a string as well as TrustedHtml. The escapers knew that for HTML objects only; TrustedJavaScript, TrustedCss and TrustedXml were handled as any other object, which |escapeJs encoded as {}. Filters |escapeHtml, |escapeJs, |escapeXml, |escapeCss, |escapeICal and |escapeHtmlComment now ask Helpers::convertTrusted() first, like a print into a template of that type: the same type passes unchanged, another one is converted and a type without a convertor throws. An HTML object in |escapeCss and |escapeICal is deprecated like printing it into CSS and iCal; the output stays. | | | |
| latte | by dg | Runtime: added TrustedUrl, which is not checked in URL attributes A URL in href, src and other URL attributes is checked by checkUrl() and the only way around was |nocheck in the template, which turns the check off for the place whatever the value is. TrustedUrl moves the decision to the PHP code that creates the URL, e.g. one with a scheme of its own. It is not a content type: anywhere else it is escaped like any other value. 90f5fdcf-a97a-42b5-bc27-65b36db215de | | | |
| latte | by dg | FilterExecutor: contextual filters get TrustedJavaScript, TrustedCss & TrustedXml as a string of their type A contextual filter in a print, {$js|trim}, got an HTML object as a string with the content type html and its result was wrapped back; the other trusted types were passed as objects of an unknown type. They are now treated the same way: the filter gets the string with the type js, css or xml and the result becomes the trusted class of the type the filter left. The class of a content type and the type of a trusted object are mapped in Helpers::getTrustedClass() and getTrustedType() only. 90f5fdcf-a97a-42b5-bc27-65b36db215de | | | |
| latte | by dg | Engine: added renderToTrusted() Returns the output as the trusted object of the content type it really has, which removes the trap of new Html($latte->renderToString(...)), where nobody checks that the output is HTML. The type comes from the template that printed the output, which with {layout} is the last one of the chain, so Template::render() returns it. A single block has the type of the place it is defined in: a block in <script> gives TrustedJavaScript, in <style> TrustedCss, a block in <title>, <textarea> or an attribute is converted to HTML. A text or iCal template and a block without a conversion to its main type (a comment, on*) throw. 90f5fdcf-a97a-42b5-bc27-65b36db215de | | | |
| latte | by dg | Helpers: printing an HTML object where its escaping differs from its conversion is deprecated TrustedHtml and other HtmlStringable objects are printed as they always were, which in some contexts is not what the table of convertors says. Where the output differs from converting content type HTML into the context, it stays and E_USER_DEPRECATED announces the change: - style, <style>, a CSS template, inside a tag, <script> of an unknown type and iCal have no conversion from HTML and will throw, - a text template keeps the markup and onclick={$html} turns its text into code; both will be converted like included HTML. In XML an HTML object is printed as XML, which {capture} relies on, so it is not deprecated there. 90f5fdcf-a97a-42b5-bc27-65b36db215de | | | |
| latte | by dg | added TrustedJavaScript, TrustedCss & TrustedXml, printed like an included template of their type Every printed value has a content type and printing converts it into the context: a string is text, a trusted object has the type of its class and goes through the same convertor as {include} of a template of that type. In its own context it is printed unchanged (</script and </style are neutralized, an attribute is encoded), elsewhere it is converted, and where no convertor exists it throws: TrustedCss printed into JS is an error of type, not a value to escape. The compiled print passes every value with its context to convertTrusted(), which returns null at once for anything that is not Stringable. Dynamic attributes and n:attr convert inside their formatters; JS attributes got the formatter formatJsAttribute() for that. 90f5fdcf-a97a-42b5-bc27-65b36db215de | | | |
| latte | by dg | Runtime: Html renamed to TrustedHtml 90f5fdcf-a97a-42b5-bc27-65b36db215de | | | |
| latte | by dg | Helpers: printing an HTML object converts it by convertTrusted(), like included HTML Each escaper used to decide by itself what an HtmlStringable object means in its context, with conditions that repeated the 'html' row of Escaper::Convertors and did not agree on Nette\HtmlStringable. The compiled print and the formatters of attributes now ask Helpers::convertTrusted(), which takes the convertor from the table; the output is the same. Kept apart from the table: a text template keeps the markup, in XML the object is XML, and Nette\HtmlStringable is a plain string in an attribute and in XML. The compiled print passes every value with its context to convertTrusted(), which returns null at once for anything that is not Stringable. The escapers still accept an HTML object for code that calls them directly. | | | |
| latte | by dg | Escaper: convertors are closures created once getConvertor() returned the name of a runtime function as a string. The return type ?callable verified it on every call, about 400 ns, and calling a function by its name costs more than calling a closure. That did not matter while the convertor was looked up once per {include}; printing a trusted object looks it up on every print. | | | |
| latte | by dg | Released version 3.1.11 | | | |
| latte | by dg | updated upgrading.md | | | |
| latte | by dg | Compiler: deprecations triggered while compiling a template name its file [Closes #436] b1de9cd3-8614-457f-a736-a384d9f2b5e5 | | | |
| latte | by dg | CompileException: a template with a null byte throws it instead of ValueError 33d0588c-d2fd-4a98-a2ea-4970a3b906f2 | | | |
| latte | by dg | docs: internals describe the traps of getIterator() 3efed8ad-6d5c-4e08-9c92-f0fd6c232e15 | | | |
| latte | by dg | docs: sandbox internals describe the checks placed when printing and further boundaries 3efed8ad-6d5c-4e08-9c92-f0fd6c232e15 | | | |
| latte | by dg | sandbox: dynamic property name is converted to string once The name was converted for the check and again for the access, so an object whose __toString() returns a different name each time passed the check with an allowed name and read another property. 3efed8ad-6d5c-4e08-9c92-f0fd6c232e15 | | | |
| latte | by dg | SecurityPolicy: createSafePolicy() does not allow filters |query and |escapeJs (BC break) Both serialize an object with all its public properties, past the policy. 3efed8ad-6d5c-4e08-9c92-f0fd6c232e15 | | | |
| latte | by dg | sandbox: filters |sort and |group read the property through the policy A name passed as 'by' or 'byKey' is read by the filter itself, where the sandbox does not see it. The sandbox replaces the name with a closure that reads the property with the policy check. 3efed8ad-6d5c-4e08-9c92-f0fd6c232e15 | | | |
| tracy | by dg | used attribute Deprecated | | | |
| tracy | by dg | error.log changed to warning.log | | | |
| tracy | by dg | Logger: added typehints WIP | | | |
| tracy | by dg | open in editor: added support for columns | | | |
| tracy | by dg | opened 3.0-dev | | | |
| tracy | by dg | Toggle: collapsed content is reachable by find-in-page Collapsed content uses hidden='until-found' so browser find-in-page reaches it and auto-expands the match. | | | |
| tracy | by dg | Logger: $notifiers hooks, mailers receive the exception report filename - Logger::$notifiers[] hooks for one-line Slack/Sentry/webhook integrations - mailers receive the exception report filename as a third argument | | | |
| tracy | by dg | Logger: machine-readable exceptions.jsonl index Every logged exception appends a JSON Lines record (time, level, hash, message, report filename, source) usable by log aggregators and AI agents. | | | |
| tracy | by dg | Debugger: reset() clears per-request state for long-running workers Re-stamps request time and output-buffer level, clears timers, barDump data, the live dump snapshot and per-request strategy state, and flushes FileSession so deferred content of the previous request is persisted. Intended for FrankenPHP worker mode, RoadRunner and Swoole. | | | |
| tracy | by dg | docs: the core of Redactor is shared with nette/mcp-inspector 12348432-f043-43cb-9b3f-4c5e49dad690 | | | |
| tracy | by dg | Redactor: credentials after an authorization scheme are hidden also alone The value of Authorization is 'Bearer <token>', so the token passed on without the scheme was not recognized as a collected value. 07800b17-5c2d-4eae-9e0f-feaffb91a497 | | | |
| tracy | by dg | docs: agents are pointed to the hiding of sensitive data 07800b17-5c2d-4eae-9e0f-feaffb91a497 | | | |