Skip to content
Permalink
Browse files Browse the repository at this point in the history
[Ecommerce] Validate pricing rule names
  • Loading branch information
brusch committed Jan 17, 2022
1 parent d8377fc commit dfaf78b
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 18 deletions.
Expand Up @@ -264,7 +264,7 @@ public function renameAction(Request $request)
$ruleNewName = $request->get('name');

try {
if ($ruleId && $ruleNewName) {
if ($ruleId && $ruleNewName && preg_match('/^[a-zA-Z0-9_\-]+$/', $ruleNewName)) {
$renameRule = Rule::getById($ruleId);

if ($renameRule->getName() != $ruleNewName) {
Expand Down
Expand Up @@ -351,26 +351,30 @@ pimcore.bundle.EcommerceFramework.pricing.config.panel = Class.create({

if (button == 'ok') {

let tree = options.tree;
if(value.match(/^[a-zA-Z0-9_\-]+$/)) {
let tree = options.tree;

Ext.Ajax.request({
url: Routing.generate('pimcore_ecommerceframework_pricing_rename'),
method: 'PUT',
params: {
id: options.id,
name: value
},
success: function (response, opts) {
Ext.Ajax.request({
url: Routing.generate('pimcore_ecommerceframework_pricing_rename'),
method: 'PUT',
params: {
id: options.id,
name: value
},
success: function (response, opts) {

let responseData = Ext.decode(response.responseText);
let responseData = Ext.decode(response.responseText);

if (responseData.success) {
this.refresh(this.tree.getRootNode());
} else {
Ext.MessageBox.alert(t('rename'), t('name_already_in_use'));
}
}.bind(this)
});
if (responseData.success) {
this.refresh(this.tree.getRootNode());
} else {
Ext.MessageBox.alert(t('rename'), t('name_already_in_use'));
}
}.bind(this)
});
} else {
Ext.Msg.alert(t('add_target'), t('problem_creating_new_target'));
}
}
},

Expand Down

0 comments on commit dfaf78b

Please sign in to comment.