[ENTITY][LocalUser] Don't use FILTER_SANITIZE_EMAIL, use just want to validate. Up to the user to fix any errors. Use setter, rather than duplicate it's code

This commit is contained in:
Hugo Sales 2022-02-26 14:43:57 +00:00
parent 5188a473d0
commit 255c44bbf0
Signed by untrusted user: someonewithpc
GPG Key ID: 7D0C7EAFC9D835A0

View File

@ -379,12 +379,10 @@ class LocalUser extends Entity implements UserInterface, PasswordAuthenticatedUs
*/ */
public function setOutgoingEmailSanitized(?string $email): self public function setOutgoingEmailSanitized(?string $email): self
{ {
$sanitized_email = filter_var($email, FILTER_SANITIZE_EMAIL); if (is_null($email) || filter_var($email, FILTER_VALIDATE_EMAIL) === false) {
if (!is_null($email) && !filter_var($sanitized_email, FILTER_VALIDATE_EMAIL)) {
throw new EmailException('Invalid email entry, please use a valid email'); throw new EmailException('Invalid email entry, please use a valid email');
} }
$this->outgoing_email = \is_null($sanitized_email) ? null : \mb_substr($sanitized_email, 0, 191); return $this->setOutgoingEmail($email);
return $this;
} }
/** /**
@ -396,12 +394,10 @@ class LocalUser extends Entity implements UserInterface, PasswordAuthenticatedUs
*/ */
public function setIncomingEmailSanitized(?string $email): self public function setIncomingEmailSanitized(?string $email): self
{ {
$sanitized_email = filter_var($email, FILTER_SANITIZE_EMAIL); if (is_null($email) || filter_var($email, FILTER_VALIDATE_EMAIL) === false) {
if (!is_null($email) && !filter_var($sanitized_email, FILTER_VALIDATE_EMAIL)) {
throw new EmailException('Invalid email entry, please use a valid email'); throw new EmailException('Invalid email entry, please use a valid email');
} }
$this->incoming_email = \is_null($sanitized_email) ? null : \mb_substr($sanitized_email, 0, 191); return $this->setIncomingEmail($email);
return $this;
} }
public function getActor(): Actor public function getActor(): Actor