1
0
mirror of https://github.com/janeczku/calibre-web synced 2025-10-17 00:27:39 +00:00

Allow deletion of kindle email address and force e-mail address to be valid

This commit is contained in:
Ozzie Isaacs
2022-08-28 15:54:43 +02:00
parent ec8844c7d4
commit 89d226e36b
3 changed files with 17 additions and 9 deletions

View File

@@ -654,11 +654,13 @@ def check_username(username):
def valid_email(email):
email = email.strip()
# Regex according to https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/email#validation
if not re.search(r"^[\w.!#$%&'*+\\/=?^_`{|}~-]+@[\w](?:[\w-]{0,61}[\w])?(?:\.[\w](?:[\w-]{0,61}[\w])?)*$",
email):
log.error(u"Invalid e-mail address format")
raise Exception(_(u"Invalid e-mail address format"))
# if email is not deleted
if email:
# Regex according to https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/email#validation
if not re.search(r"^[\w.!#$%&'*+\\/=?^_`{|}~-]+@[\w](?:[\w-]{0,61}[\w])?(?:\.[\w](?:[\w-]{0,61}[\w])?)*$",
email):
log.error(u"Invalid e-mail address format")
raise Exception(_(u"Invalid e-mail address format"))
return email
# ################################# External interface #################################