fix: a data attribute is escaped like everything else the theme renders - #927
Merged
blaipr merged 1 commit intoSep 17, 2026
Merged
Conversation
Eight places in four templates emitted data-<name>="<value>" out of a DataGridAction::getData()/getRuntimeData() map with no escaping at all. Nothing leaks today — every current addData() passes an ACL route or an integer id, and FileGrid's item-type must match the administrator's own MIME allow-list exactly — but nothing in the templates or in DataGridActionBase constrains what a caller may pass, and one addData() carrying a name, a login or a note breaks straight out of the attribute. data-onclick was unescaped the same way. ThemeEscapesWhatItRendersTest decides what carries text by the getter's name or by $_getvar(, so a bare $dataValue in a loop matched neither: the rule that holds the rest of the theme to escaping-on-output had a blind spot exactly where a caller-supplied map is rendered. aDataAttributeMapIsEscaped() closes it narrowly — only the loops whose attribute name is itself a variable, which are precisely the ones taking an arbitrary map. Writing the guard found more than the review did: it named three sites, and the scan found five more, in _partials/fixed-header.inc and grid/datagrid-grid.inc.
blaipr
deleted the
fix/a-data-attribute-is-escaped-like-everything-else
branch
September 17, 2026 02:11
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.
Eight places in four templates emitted
data-<name>="<value>"out of aDataGridAction::getData()/getRuntimeData()map with no escaping at all — not$_e(), notanything:
Nothing is leaking today: every current
addData()/setRuntimeData()call passes an ACL routestring or an integer id. The one value that is not a literal is
FileGrid'sitem-type, a MIME typethat
AllowedMimeType::resolve()requires to match the administrator's own allow-list exactly, soputting a quote there is self-inflicted.
But nothing in the templates or in
DataGridActionBaseconstrains what a caller may pass, and oneaddData()carrying a name, a login or a note breaks straight out of the attribute.data-onclickwas unescaped the same way.
Why the existing guard could not see it
ThemeEscapesWhatItRendersTestdecides what carries text by the getter's name (getName,getLogin, …) or by$_getvar(. A bare$dataValuein a loop matches neither, so the rule thatholds the rest of the theme to escaping-on-output had a blind spot exactly where a caller-supplied
map is rendered.
aDataAttributeMapIsEscaped()closes it, narrowly: it looks only at the loops whose attributename is itself a variable — which are precisely the ones taking an arbitrary map — and requires
$_e(in the emitting expression. A fixeddata-item-id="<?php echo $id; ?>"is an id byconstruction and stays with the rule above.
Writing the guard found more than the audit did
The review that started this named three sites, in
datagrid-rows.incandsearch-rows.inc. Theguard, run against the source, found five more: two in
_partials/fixed-header.incand three ingrid/datagrid-grid.inc. That is the whole argument for scanning rather than fixing a list.Tests
Mutation-verified: reverting
public/fails the guard on four templates, naming all sixteenoccurrences.