Skip to content

Commit

Permalink
[Task] Optimized composite index key (#14636)
Browse files Browse the repository at this point in the history
* chore: validate composite index key

* fix: add php validation
  • Loading branch information
lukmzig committed Mar 21, 2023
1 parent 27fca61 commit 765832f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
Expand Up @@ -455,6 +455,14 @@ public function saveAction(Request $request)
$class->rename($values['name']);
}

if ($values['compositeIndices']) {
foreach ($values['compositeIndices'] as $index => $compositeIndex) {
if ($compositeIndex['index_key'] !== ($sanitizedKey = preg_replace('/[^a-za-z0-9_\-+]/', '', $compositeIndex['index_key']))) {
$values['compositeIndices'][$index]['index_key'] = $sanitizedKey;
}
}
}

unset($values['creationDate']);
unset($values['userOwner']);
unset($values['layoutDefinitions']);
Expand Down
Expand Up @@ -1085,7 +1085,14 @@ pimcore.object.classes.klass = Class.create({
fieldLabel: t("key"),
labelWidth: 100,
width: 250,
value: data.index_key
value: data.index_key,
validator: function (value) {
if(value !== value.replace(/[^a-za-z0-9_\-+]/g,'')){
this.setvalue(value.replace(/[^a-za-z0-9_\-+]/g,''));
}

return true;
}
};

//fixes data to match store model
Expand Down

0 comments on commit 765832f

Please sign in to comment.