mirror of
https://github.com/caronc/apprise.git
synced 2024-11-22 08:04:02 +01:00
Allow extended characters in ID of email address (#693)
This commit is contained in:
parent
cb7f51d82a
commit
b989427215
@ -129,7 +129,8 @@ class NotifyForm(NotifyBase):
|
||||
},
|
||||
}
|
||||
|
||||
def __init__(self, headers=None, method=None, payload=None, params=None, **kwargs):
|
||||
def __init__(self, headers=None, method=None, payload=None, params=None,
|
||||
**kwargs):
|
||||
"""
|
||||
Initialize Form Object
|
||||
|
||||
|
@ -136,7 +136,8 @@ class NotifyXML(NotifyBase):
|
||||
},
|
||||
}
|
||||
|
||||
def __init__(self, headers=None, method=None, payload=None, params=None, **kwargs):
|
||||
def __init__(self, headers=None, method=None, payload=None, params=None,
|
||||
**kwargs):
|
||||
"""
|
||||
Initialize XML Object
|
||||
|
||||
|
@ -153,10 +153,10 @@ URL_DETAILS_RE = re.compile(
|
||||
# - user@example.com
|
||||
# - label+user@example.com
|
||||
GET_EMAIL_RE = re.compile(
|
||||
r'(([\s"\']+)?(?P<name>[^:<"\']+)?[:<\s"\']+)?'
|
||||
r'(([\s"\']+)?(?P<name>[^:<\'"]+)?[:<\s\'"]+)?'
|
||||
r'(?P<full_email>((?P<label>[^+]+)\+)?'
|
||||
r'(?P<email>(?P<userid>[a-z0-9$%=_~-]+'
|
||||
r'(?:\.[a-z0-9$%+=_~-]+)'
|
||||
r'(?P<email>(?P<userid>[a-z0-9_!#$%&*/=?%`{|}~^-]+'
|
||||
r'(?:\.[a-z0-9_!#$%&\'*/=?%`{|}~^-]+)'
|
||||
r'*)@(?P<domain>('
|
||||
r'(?:[a-z0-9](?:[a-z0-9_-]*[a-z0-9])?\.)+'
|
||||
r'[a-z0-9](?:[a-z0-9_-]*[a-z0-9]))|'
|
||||
@ -188,7 +188,7 @@ URL_DETECTION_RE = re.compile(
|
||||
|
||||
EMAIL_DETECTION_RE = re.compile(
|
||||
r'[\s,]*([^@]+@.*?)(?=$|[\s,]+'
|
||||
+ r'(?:[^:<]+?[:<\s]+?)?'
|
||||
r'(?:[^:<]+?[:<\s]+?)?'
|
||||
r'[^@\s,]+@[^\s,]+)',
|
||||
re.IGNORECASE)
|
||||
|
||||
|
@ -1361,6 +1361,30 @@ def test_is_email():
|
||||
assert utils.is_email("Just A Name") is False
|
||||
assert utils.is_email("Name <bademail>") is False
|
||||
|
||||
# Extended valid emails
|
||||
#
|
||||
# The first + denotes our label, so this test really validates
|
||||
# that there is a correct split and parsing of our email
|
||||
results = utils.is_email('a-z0-9_!#$%&*+/=?%`{|}~^.-@gmail.com')
|
||||
assert '' == results['name']
|
||||
assert 'a-z0-9_!#$%&*' == results['label']
|
||||
assert '/=?%`{|}~^.-@gmail.com' == results['email']
|
||||
assert 'a-z0-9_!#$%&*+/=?%`{|}~^.-@gmail.com' == results['full_email']
|
||||
assert 'gmail.com' == results['domain']
|
||||
assert '/=?%`{|}~^.-' == results['user']
|
||||
|
||||
# A similar test without '+' (use of a label)
|
||||
|
||||
# The first + denotes our label, so this test really validates
|
||||
# that there is a correct split and parsing of our email
|
||||
results = utils.is_email('a-z0-9_!#$%&*/=?%`{|}~^.-@gmail.com')
|
||||
assert '' == results['name']
|
||||
assert '' == results['label']
|
||||
assert 'a-z0-9_!#$%&*/=?%`{|}~^.-@gmail.com' == results['email']
|
||||
assert 'a-z0-9_!#$%&*/=?%`{|}~^.-@gmail.com' == results['full_email']
|
||||
assert 'gmail.com' == results['domain']
|
||||
assert 'a-z0-9_!#$%&*/=?%`{|}~^.-' == results['user']
|
||||
|
||||
|
||||
def test_is_call_sign_no():
|
||||
"""
|
||||
|
@ -504,6 +504,7 @@ urls:
|
||||
- invalid: test
|
||||
- sns://T1JJ3T3L2/:
|
||||
- invalid: test
|
||||
- _invalid: Token can not start with an underscore
|
||||
|
||||
# some strangeness
|
||||
-
|
||||
|
@ -191,7 +191,7 @@ TEST_URLS = (
|
||||
'response': False,
|
||||
}),
|
||||
# Valid URL, but can't structure a proper email
|
||||
('mailtos://nuxref.com?user=%20!&pass=.', {
|
||||
('mailtos://nuxref.com?user=%20"&pass=.', {
|
||||
'instance': TypeError,
|
||||
}),
|
||||
# Invalid From (and To) Address
|
||||
|
@ -58,7 +58,7 @@ apprise_url_tests = (
|
||||
'instance': TypeError,
|
||||
}),
|
||||
# Invalid from email address
|
||||
('mailgun://!@localhost.localdomain/{}-{}-{}'.format(
|
||||
('mailgun://"@localhost.localdomain/{}-{}-{}'.format(
|
||||
'a' * 32, 'b' * 8, 'c' * 8), {
|
||||
'instance': TypeError,
|
||||
}),
|
||||
|
@ -58,7 +58,7 @@ apprise_url_tests = (
|
||||
'instance': TypeError,
|
||||
}),
|
||||
# Invalid from email address
|
||||
('smtp2go://!@localhost.localdomain/{}-{}-{}'.format(
|
||||
('smtp2go://"@localhost.localdomain/{}-{}-{}'.format(
|
||||
'a' * 32, 'b' * 8, 'c' * 8), {
|
||||
'instance': TypeError,
|
||||
}),
|
||||
|
@ -59,7 +59,7 @@ apprise_url_tests = (
|
||||
'instance': TypeError,
|
||||
}),
|
||||
# Invalid from email address
|
||||
('sparkpost://!@localhost.localdomain/{}'.format('b' * 32), {
|
||||
('sparkpost://"@localhost.localdomain/{}'.format('b' * 32), {
|
||||
'instance': TypeError,
|
||||
}),
|
||||
# No To email address, but everything else is valid
|
||||
|
Loading…
Reference in New Issue
Block a user