Skip to content

Commit

Permalink
[Custom Reports] Validate & escape CSS classes and names
Browse files Browse the repository at this point in the history
  • Loading branch information
brusch committed Jan 17, 2022
1 parent d8377fc commit dff1cb0
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 7 deletions.
Expand Up @@ -289,13 +289,13 @@ public function getReportConfigAction(Request $request)

foreach ($items as $report) {
$reports[] = [
'name' => $report->getName(),
'niceName' => $report->getNiceName(),
'iconClass' => $report->getIconClass(),
'group' => $report->getGroup(),
'groupIconClass' => $report->getGroupIconClass(),
'name' => htmlspecialchars($report->getName()),
'niceName' => htmlspecialchars($report->getNiceName()),
'iconClass' => htmlspecialchars($report->getIconClass()),
'group' => htmlspecialchars($report->getGroup()),
'groupIconClass' => htmlspecialchars($report->getGroupIconClass()),
'menuShortcut' => $report->getMenuShortcut(),
'reportClass' => $report->getReportClass(),
'reportClass' => htmlspecialchars($report->getReportClass()),
];
}

Expand Down
Expand Up @@ -894,7 +894,25 @@ pimcore.report.custom.item = Class.create({

save: function () {

var m = this.getValues();
let m = this.getValues();
let error = false;

['group', 'groupIconClass', 'iconClass', 'niceName', 'reportClass'].forEach(function (name) {
if(m[name].length && !m[name].match(/^[_a-zA-Z]+[_a-zA-Z0-9-\s]*$/)) {
error = name;
}
});

if(error !== false) {
Ext.Msg.show({
title: t("error"),
msg: t('class_field_name_error') + ': ' + error,
buttons: Ext.Msg.OK,
icon: Ext.MessageBox.ERROR
});

return;
}

Ext.Ajax.request({
url: Routing.generate('pimcore_admin_reports_customreport_update'),
Expand Down

0 comments on commit dff1cb0

Please sign in to comment.