[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: someonewithpc
GPG Key ID: 7D0C7EAFC9D835A0

View File

@ -379,12 +379,10 @@ class LocalUser extends Entity implements UserInterface, PasswordAuthenticatedUs
*/
public function setOutgoingEmailSanitized(?string $email): self
{
$sanitized_email = filter_var($email, FILTER_SANITIZE_EMAIL);
if (!is_null($email) && !filter_var($sanitized_email, FILTER_VALIDATE_EMAIL)) {
if (is_null($email) || filter_var($email, FILTER_VALIDATE_EMAIL) === false) {
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;
return $this->setOutgoingEmail($email);
}
/**
@ -396,12 +394,10 @@ class LocalUser extends Entity implements UserInterface, PasswordAuthenticatedUs
*/
public function setIncomingEmailSanitized(?string $email): self
{
$sanitized_email = filter_var($email, FILTER_SANITIZE_EMAIL);
if (!is_null($email) && !filter_var($sanitized_email, FILTER_VALIDATE_EMAIL)) {
if (is_null($email) || filter_var($email, FILTER_VALIDATE_EMAIL) === false) {
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;
return $this->setIncomingEmail($email);
}
public function getActor(): Actor