Remove XMPP address if invalid

main
Bob Mottram 2020-07-06 11:27:10 +01:00
parent dd8650b717
commit d203262084
1 changed files with 9 additions and 6 deletions

15
xmpp.py
View File

@ -36,6 +36,14 @@ def getXmppAddress(actorJson: {}) -> str:
def setXmppAddress(actorJson: {}, xmppAddress: str) -> None: def setXmppAddress(actorJson: {}, xmppAddress: str) -> None:
"""Sets an xmpp address for the given actor """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'): if not actorJson.get('attachment'):
actorJson['attachment'] = [] actorJson['attachment'] = []
@ -53,12 +61,7 @@ def setXmppAddress(actorJson: {}, xmppAddress: str) -> None:
break break
if propertyFound: if propertyFound:
actorJson['attachment'].remove(propertyFound) actorJson['attachment'].remove(propertyFound)
if notXmppAddress:
if '@' not in xmppAddress:
return
if '.' not in xmppAddress:
return
if '"' in xmppAddress:
return return
for propertyValue in actorJson['attachment']: for propertyValue in actorJson['attachment']: