Limit length of accepted email addresses (#9855)

This commit is contained in:
Erik Johnston 2021-04-22 17:49:11 +01:00 committed by GitHub
parent 69018acbd2
commit 177dae2704
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 100 additions and 7 deletions

View file

@ -19,8 +19,9 @@ from twisted.internet.error import AlreadyCalled, AlreadyCancelled
from twisted.internet.interfaces import IDelayedCall
from synapse.metrics.background_process_metrics import run_as_background_process
from synapse.push import Pusher, PusherConfig, ThrottleParams
from synapse.push import Pusher, PusherConfig, PusherConfigException, ThrottleParams
from synapse.push.mailer import Mailer
from synapse.util.threepids import validate_email
if TYPE_CHECKING:
from synapse.server import HomeServer
@ -71,6 +72,12 @@ class EmailPusher(Pusher):
self._is_processing = False
# Make sure that the email is valid.
try:
validate_email(self.email)
except ValueError:
raise PusherConfigException("Invalid email")
def on_started(self, should_check_for_notifs: bool) -> None:
"""Called when this pusher has been started.