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:
"""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']: