Skip to content

Commit 874bad3

Browse files
Merge pull request #243 from matomo-org/escape-report_matched
Adds escaping for report_matched value
2 parents 7d5ffb4 + 788575a commit 874bad3

4 files changed

Lines changed: 17 additions & 2 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
## Changelog
22

3+
* 5.2.5 - 2026-03-30 - Added escaping for report_matched value
34
* 5.2.4 - 2026-03-02 - Updated API documentation
45
* 5.2.3 - 2026-02-05 - Alerts now get deleted when a user's site access is revoked
56
* 5.2.2 - 2026-01-19 - Added tooltips in add/edit alerts, manage alerts & in the inline text for the delivery method

plugin.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "CustomAlerts",
33
"description": "Create custom Alerts to be notified of important changes on your website or app! ",
4-
"version": "5.2.4",
4+
"version": "5.2.5",
55
"require": {
66
"matomo": ">=5.0.0-b1,<6.0.0-b1"
77
},

templates/htmlTriggeredAlerts.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
{% endif %}
3030
<td style="{% if not extended %}{{styleTableCell}}{% else %}max-width:300px;{% endif %}{{ style }}">{{ alert.reportName|default(alert.report)|rawSafeDecoded }}</td>
3131
{% if hasConditions %}
32-
<td style="{% if not extended %}{{styleTableCell}}{% else %}max-width:300px;{% endif %}{{ style }}">{{ alert.dimension|default('') }} {{ alert.reportConditionName }} {% if alert.report_matched %}'{{ alert.report_matched|truncate(100)|raw }}'{% endif %}</td>
32+
<td style="{% if not extended %}{{styleTableCell}}{% else %}max-width:300px;{% endif %}{{ style }}">{{ alert.dimension|default('') }} {{ alert.reportConditionName }} {% if alert.report_matched %}'{{ alert.report_matched|truncate(100)|rawSafeDecoded }}'{% endif %}</td>
3333
{% endif %}
3434
<td style="{% if not extended %}{{styleTableCell}}{% else %}max-width:300px;{% endif %}{{ style }}padding:17px 10px;">{{ alert.reportMetric }} {{ alertsMacro.metricChangeDescription(alert) }}</td>
3535
</tr>

tests/Integration/ControllerTest.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,20 @@ public function test_formatAlertsNoConditions_asHtml()
228228
$this->assertEquals($expected, $rendered, "Got following HTML response: " . var_export($rendered, true));
229229
}
230230

231+
public function test_formatAlerts_asHtml_shouldEscapeReportMatched()
232+
{
233+
$payload = '<img src=x onerror=alert(1)>';
234+
$alerts = array(
235+
$this->buildAlert(1, 'MyName1', 'week', 1, 'Piwik test', 'superUserLogin', 'nb_visits', 'decrease_more_than', 5000, 'MultiSites_getOne', 'matches_exactly', $payload)
236+
);
237+
238+
$rendered = $this->controller->formatAlerts($alerts, 'html');
239+
240+
$this->assertStringContainsString("Website is '&lt;img src=x onerror=alert(1)&gt;'", $rendered);
241+
$this->assertStringNotContainsString("'{$payload}'", $rendered);
242+
$this->assertStringNotContainsString("<img src=x onerror=alert(1)>", $rendered);
243+
}
244+
231245
public function test_enrichTriggeredAlerts_shouldEnrichAlerts_IfReportExistsAndMetricIsValid()
232246
{
233247
$timestamp = 1389824417;

0 commit comments

Comments
 (0)