Skip to content

Commit 8a6c1af

Browse files
committed
catch canonicalise_email value error in auth handler
Signed-off-by: qashlan <[email protected]> Signed-off-by: Ahmed Qashlan <[email protected]>
1 parent ac1bf68 commit 8a6c1af

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

synapse/handlers/auth.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1579,7 +1579,10 @@ async def add_threepid(
15791579
# for the presence of an email address during password reset was
15801580
# case sensitive).
15811581
if medium == "email":
1582-
address = canonicalise_email(address)
1582+
try:
1583+
address = canonicalise_email(address)
1584+
except ValueError as e:
1585+
raise SynapseError(400, str(e))
15831586

15841587
await self.store.user_add_threepid(
15851588
user_id, medium, address, validated_at, self.hs.get_clock().time_msec()
@@ -1610,7 +1613,10 @@ async def delete_local_threepid(
16101613
"""
16111614
# 'Canonicalise' email addresses as per above
16121615
if medium == "email":
1613-
address = canonicalise_email(address)
1616+
try:
1617+
address = canonicalise_email(address)
1618+
except ValueError as e:
1619+
raise SynapseError(400, str(e))
16141620

16151621
await self.store.user_delete_threepid(user_id, medium, address)
16161622

0 commit comments

Comments
 (0)