mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
More email address validation
This commit is contained in:
parent
9c2c036702
commit
a107534286
@ -245,6 +245,10 @@ class SelectRecipients(QDialog): # {{{
|
||||
if not to:
|
||||
return error_dialog(
|
||||
self, _('Need address'), _('You must specify an address'), show=True)
|
||||
from email.utils import parseaddr
|
||||
if not parseaddr(to)[-1] or '@' not in to:
|
||||
return error_dialog(
|
||||
self, _('Invalid email address'), _('The address {} is invalid').format(to), show=True)
|
||||
formats = ','.join([x.strip().upper() for x in str(self.formats.text()).strip().split(',') if x.strip()])
|
||||
if not formats:
|
||||
return error_dialog(
|
||||
|
@ -150,7 +150,7 @@ class EmailAccounts(QAbstractTableModel): # {{{
|
||||
na = as_unicode(value or '')
|
||||
from email.utils import parseaddr
|
||||
addr = parseaddr(na)[-1]
|
||||
if not addr:
|
||||
if not addr or '@' not in na:
|
||||
return False
|
||||
self.accounts[na] = self.accounts.pop(account)
|
||||
self.account_order[row] = na
|
||||
|
@ -68,8 +68,9 @@ class TestEmail(QDialog):
|
||||
|
||||
def run_test(self):
|
||||
from email.utils import parseaddr
|
||||
addr = parseaddr(self.to.text().strip())[-1]
|
||||
if not addr:
|
||||
q = self.to.text().strip()
|
||||
addr = parseaddr(q)[-1]
|
||||
if not addr or '@' not in q:
|
||||
tb = f'{self.to.text().strip()} is not a valid email address'
|
||||
else:
|
||||
try:
|
||||
|
Loading…
x
Reference in New Issue
Block a user