Handle sanitization as early as possible per best practices

Per WP security best practices, sanitization should be handled as early
as possible. So this commit move updates the calls to sanitize the
segment name and description to the part of the code where the user
input is first processed, instead of when the data is saved to the
database.

[MAILPOET-5232]
This commit is contained in:
Rodrigo Primo
2023-04-17 11:30:40 -03:00
parent db23bffee1
commit aa5b052e66
5 changed files with 12 additions and 6 deletions

View File

@ -105,6 +105,8 @@ class DynamicSegments extends APIEndpoint {
public function save($data) {
try {
$data['name'] = isset($data['name']) ? sanitize_text_field($data['name']) : '';
$data['description'] = isset($data['description']) ? sanitize_textarea_field($data['description']) : '';
$segment = $this->saveController->save($data);
return $this->successResponse($this->segmentsResponseBuilder->build($segment));
} catch (InvalidFilterException $e) {