Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/1.5' into 1.x
Browse files Browse the repository at this point in the history
  • Loading branch information
mcop1 committed Mar 29, 2023
2 parents 16b2a02 + 1697905 commit ee161be
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/Resources/public/js/pimcore/perspective/perspective.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ pimcore.bundle.perspectiveeditor.PerspectiveEditor = class {
disabled: !pimcore.settings['perspectives-writeable'],
handler: function(){
Ext.MessageBox.prompt(t('plugin_pimcore_perspectiveeditor_new_perspective'), t('plugin_pimcore_perspectiveeditor_new_perspective'), function (button, value) {
value = this.sanitizeName(value);

if (button === 'ok' && value.length > 0) {
//check for configs with same name
let match = this.perspectiveTreeStore.findExact("name", value);
Expand Down Expand Up @@ -824,4 +826,8 @@ pimcore.bundle.perspectiveeditor.PerspectiveEditor = class {
}
}
}

sanitizeName (name) {
return name.replace(/[^a-z0-9_\-.+]/gi,'');
}
}
6 changes: 6 additions & 0 deletions src/Resources/public/js/pimcore/perspective/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ pimcore.bundle.perspectiveeditor.ViewEditor = class {
disabled: !pimcore.settings['custom-views-writeable'],
handler: function () {
Ext.MessageBox.prompt(t('plugin_pimcore_perspectiveeditor_new_view'), t('plugin_pimcore_perspectiveeditor_new_view'), function (button, value) {
value = this.sanitizeName(value);

if (button === 'ok' && value.length > 0) {
const record = this.viewTreeStore.getRoot().appendChild({
id: pimcore.bundle.perspectiveeditor.PerspectiveViewHelper.generateUuid(),
Expand Down Expand Up @@ -567,4 +569,8 @@ pimcore.bundle.perspectiveeditor.ViewEditor = class {
}
}
}

sanitizeName (name) {
return name.replace(/[^a-z0-9_\-.+]/gi,'');
}
}
2 changes: 1 addition & 1 deletion src/Services/PerspectiveAccessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ protected function convertTreeStoreToConfiguration($treeStore)
$configuration = [];

foreach ($treeStore['children'] as $child) {
$name = $child['name'];
$name = htmlspecialchars($child['name']);
$configuration[$name] = [];
$configuration[$name]['elementTree'] = [];
foreach ($child['children'] as $index => $element) {
Expand Down
4 changes: 4 additions & 0 deletions src/Services/ViewAccessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ protected function convertTreeStoreToConfiguration($treeStore)

if (isset($treeStore['children'])) {
foreach ($treeStore['children'] as $child) {
if (array_key_exists('name', $child['config'])) {
$child['config']['name'] = htmlspecialchars($child['config']['name']);
}

if (!empty($child['config']['treeContextMenu'])) {
foreach (array_keys($child['config']['treeContextMenu']) as $contextMenuEntry) {
if (substr($child['config']['treetype'], 0, strlen($contextMenuEntry)) != $contextMenuEntry) {
Expand Down

0 comments on commit ee161be

Please sign in to comment.