Repository navigation
Conversation
vrana
commented
Sep 28, 2026
Member
- new feature
- BC break? no
- doc PR: latte: documented Extension::getAttributeContexts() docs#1097
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.
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".
…BC break)
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 as HTML text
first and as an attribute second (HtmlHelpers::escapeHtmlAttr). 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).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ly rendered as HTML
With Feature::MigrationWarnings, a plain srcdoc value that renders as a different
document now than before (it contains '<' or a character reference) triggers
a warning suggesting to wrap trusted HTML in Latte\Runtime\Html. Text such as
'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.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…reak)
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.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…locale, instead of NumberFormatter's default half-even
Member
|
I'd like to take this, with one change in shape: let the built-in contexts be the default entries of the same table instead of the hard-coded checks, i.e. |
In {include}, {embed}, {extends}, {layout} and {import} 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.
Arrays of n:attr and n:class are not affected.
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.
Vue, petite-vue and AngularJS read the DOM after the browser has decoded entities, so the &nette#123; 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. escapeRawHtml() for <script type="text/template"> did not separate braces at all, so Vue evaluated {{ }} from a variable there.
Their content is text that the browser does not parse as HTML, so the empty
comment separating braces was displayed and corrupted the value, e.g. a {{ }}
in a submitted form (nette#409). The content now gets the subType rcdata, printed
by HtmlHelpers::escapeRcData() without touching braces.
A block placed in <textarea> or <title> has the content type html/rcdata,
which contextual filters now see instead of html; |stripHtml and |stripTags
accept it.
…s as JS, CSS or HTML
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 then escaped exactly like
on*, style or srcdoc: static values via the Escaper subType, dynamic attributes
(name={$x}) and n:attr via classifyAttributeType(), which now takes the map.
n:attr receives it as a compiled argument only when some context is registered.
Built-in contexts can't be overridden (on*, style, srcdoc and prefixes like s*
are rejected). The map is part of the configuration signature, so extensions
don't have to include it in getCacheKey().
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…tributes as JS, CSS or HTML The built-in contexts are the default entries of the same table (HtmlHelpers::AttributeContexts: on*, style, srcdoc) and extensions only add to it. enterHtmlAttribute() and classifyAttributeType() ask matchAttributeContext() alone; the hard-coded checks of on*, style and srcdoc are gone. Overriding a built-in stays an exception. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
vrana
force-pushed
the
attribute-contexts
branch
from
October 29, 2026 06:34
3bd7dfa to
bdb1f41
Compare
Member
Author
|
Makes sense, done. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.