From d20326208454f4ada4431b9d1b38a4951e3e56da Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Mon, 6 Jul 2020 11:27:10 +0100 Subject: [PATCH] Remove XMPP address if invalid --- xmpp.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/xmpp.py b/xmpp.py index 58dd6a99a..7972a4ad1 100644 --- a/xmpp.py +++ b/xmpp.py @@ -36,6 +36,14 @@ def getXmppAddress(actorJson: {}) -> str: def setXmppAddress(actorJson: {}, xmppAddress: str) -> None: """Sets an xmpp address for the given actor """ + notXmppAddress = False + if '@' not in xmppAddress: + notXmppAddress = True + if '.' not in xmppAddress: + notXmppAddress = True + if '"' in xmppAddress: + notXmppAddress = True + if not actorJson.get('attachment'): actorJson['attachment'] = [] @@ -53,12 +61,7 @@ def setXmppAddress(actorJson: {}, xmppAddress: str) -> None: break if propertyFound: actorJson['attachment'].remove(propertyFound) - - if '@' not in xmppAddress: - return - if '.' not in xmppAddress: - return - if '"' in xmppAddress: + if notXmppAddress: return for propertyValue in actorJson['attachment']: