mirror of https://github.com/caronc/apprise
enforce E.164 format
parent
b7f9320941
commit
ff3b57f5a4
|
@ -169,9 +169,8 @@ class NotifyPlivo(NotifyBase):
|
|||
self.logger.warning(msg)
|
||||
raise TypeError(msg)
|
||||
|
||||
# Store our source
|
||||
self.source = '{}{}'.format(
|
||||
'' if source[0] != '+' else '+', result['full'])
|
||||
# Store our source; enforce E.164 format
|
||||
self.source = f'+{result["full"]}'
|
||||
|
||||
# Parse our targets
|
||||
self.targets = list()
|
||||
|
@ -181,9 +180,8 @@ class NotifyPlivo(NotifyBase):
|
|||
# Validate targets and drop bad ones:
|
||||
result = is_phone_no(target)
|
||||
if result:
|
||||
# store valid phone number
|
||||
self.targets.append('{}{}'.format(
|
||||
'' if target[0] != '+' else '+', result['full']))
|
||||
# store valid phone number; enforce E.164 format
|
||||
self.targets.append(f'+{result["full"]}')
|
||||
continue
|
||||
|
||||
self.logger.warning(
|
||||
|
@ -331,7 +329,7 @@ class NotifyPlivo(NotifyBase):
|
|||
token=self.pprint(self.token, privacy, safe=''),
|
||||
source=self.source,
|
||||
targets='/'.join(
|
||||
[NotifyPlivo.quote(x, safe='') for x in self.targets]),
|
||||
[NotifyPlivo.quote(x, safe='+') for x in self.targets]),
|
||||
params=NotifyPlivo.urlencode(params))
|
||||
|
||||
def __len__(self):
|
||||
|
|
|
@ -83,7 +83,7 @@ apprise_url_tests = (
|
|||
('plivo://?id={}&token={}&from=15551233000&to=15551232000'.format(
|
||||
'a' * 25, 'a' * 40), {
|
||||
# Our expected url(privacy=True) startswith() response:
|
||||
'privacy_url': 'plivo://a...a@a...a/15551233000/15551232000',
|
||||
'privacy_url': 'plivo://a...a@a...a/+15551233000/+15551232000',
|
||||
# reference to to= and from=
|
||||
'instance': NotifyPlivo,
|
||||
}),
|
||||
|
@ -92,7 +92,7 @@ apprise_url_tests = (
|
|||
# reference to to= and from=
|
||||
'instance': NotifyPlivo,
|
||||
# Our expected url(privacy=True) startswith() response:
|
||||
'privacy_url': 'plivo://a...a@a...a/15551233000/15551232123'}),
|
||||
'privacy_url': 'plivo://a...a@a...a/+15551233000/+15551232123'}),
|
||||
('plivo://{}@{}/15551232000'.format('a' * 25, 'a' * 40), {
|
||||
'instance': NotifyPlivo,
|
||||
# throw a bizzare code forcing us to fail to look it up
|
||||
|
|
Loading…
Reference in New Issue