diff --git a/apprise/plugins/plivo.py b/apprise/plugins/plivo.py index df2f428d..d4c97ef3 100644 --- a/apprise/plugins/plivo.py +++ b/apprise/plugins/plivo.py @@ -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): diff --git a/test/test_plugin_plivo.py b/test/test_plugin_plivo.py index 63a3b4b3..bb742a82 100644 --- a/test/test_plugin_plivo.py +++ b/test/test_plugin_plivo.py @@ -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