Sanitize name and description when creating a segment
This commits adds the sanitization right before the data is added to the database (\MailPoet\Segments\SegmentsRepository::createOrUpdate()) and removes the sanitization from \MailPoet\Segments\DynamicSegments\SegmentSaveController::save() to avoid sanitizing twice. save() calls createOrUpdate(). Before this commit, we were sanitizing the name and description of dynamic segments but not regular segments. [MAILPOET-5232]
This commit is contained in:
@@ -31,8 +31,8 @@ class SegmentSaveController {
|
||||
*/
|
||||
public function save(array $data = []): SegmentEntity {
|
||||
$id = isset($data['id']) ? (int)$data['id'] : null;
|
||||
$name = isset($data['name']) ? sanitize_text_field($data['name']) : '';
|
||||
$description = isset($data['description']) ? sanitize_textarea_field($data['description']) : '';
|
||||
$name = $data['name'] ?? '';
|
||||
$description = $data['description'] ?? '';
|
||||
$filtersData = $this->filterDataMapper->map($data);
|
||||
|
||||
return $this->segmentsRepository->createOrUpdate($name, $description, SegmentEntity::TYPE_DYNAMIC, $filtersData, $id);
|
||||
|
Reference in New Issue
Block a user