From dd8650b717f089bd99f216ab9f93516b01f9aa0d Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Mon, 6 Jul 2020 11:25:18 +0100 Subject: [PATCH] Remove email address if invalid --- pgp.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/pgp.py b/pgp.py index a9205606f..f8dad7261 100644 --- a/pgp.py +++ b/pgp.py @@ -78,6 +78,14 @@ def getPGPfingerprint(actorJson: {}) -> str: def setEmailAddress(actorJson: {}, emailAddress: str) -> None: """Sets the email address for the given actor """ + notEmailAddress = False + if '@' not in emailAddress: + notEmailAddress = True + if '.' not in emailAddress: + notEmailAddress = True + if emailAddress.startswith('@'): + notEmailAddress = True + if not actorJson.get('attachment'): actorJson['attachment'] = [] @@ -94,12 +102,7 @@ def setEmailAddress(actorJson: {}, emailAddress: str) -> None: break if propertyFound: actorJson['attachment'].remove(propertyFound) - - if '@' not in emailAddress: - return - if '.' not in emailAddress: - return - if emailAddress.startswith('@'): + if notEmailAddress: return for propertyValue in actorJson['attachment']: