From bacc38eff2e935ffe7137c2b9a857a2d3c2cdea0 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Mon, 6 Jul 2020 11:21:09 +0100 Subject: [PATCH] Remove tox address if invalid --- tox.py | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/tox.py b/tox.py index fe37a8fe6..1be44754d 100644 --- a/tox.py +++ b/tox.py @@ -43,6 +43,21 @@ def getToxAddress(actorJson: {}) -> str: def setToxAddress(actorJson: {}, toxAddress: str) -> None: """Sets an tox address for the given actor """ + notToxAddress = False + + if len(toxAddress) != 76: + notToxAddress = True + if toxAddress.upper() != toxAddress: + notToxAddress = True + if '"' in toxAddress: + notToxAddress = True + if ' ' in toxAddress: + notToxAddress = True + if '.' in toxAddress: + notToxAddress = True + if ',' in toxAddress: + notToxAddress = True + if not actorJson.get('attachment'): actorJson['attachment'] = [] @@ -59,18 +74,7 @@ def setToxAddress(actorJson: {}, toxAddress: str) -> None: break if propertyFound: actorJson['attachment'].remove(propertyFound) - - if len(toxAddress) != 76: - return - if toxAddress.upper() != toxAddress: - return - if '"' in toxAddress: - return - if ' ' in toxAddress: - return - if '.' in toxAddress: - return - if ',' in toxAddress: + if notToxAddress: return for propertyValue in actorJson['attachment']: