Philipp Hörist pushed to branch master at gajim / python-nbxmpp

Commits:

2 changed files:

Changes:

  • nbxmpp/modules/blocking.py
    ... ... @@ -52,9 +52,15 @@ class Blocking(BaseModule):
    52 52
             if blocklist is None:
    
    53 53
                 raise MalformedStanzaError('blocklist node missing', result)
    
    54 54
     
    
    55
    -        blocked = []
    
    55
    +        blocked = set()
    
    56 56
             for item in blocklist.getTags('item'):
    
    57
    -            blocked.append(item.getAttr('jid'))
    
    57
    +            try:
    
    58
    +                jid = JID.from_string(item.getAttr('jid'))
    
    59
    +            except Exception:
    
    60
    +                self._log.info('Invalid JID: %s', item.getAttr('jid'))
    
    61
    +                continue
    
    62
    +
    
    63
    +            blocked.add(jid)
    
    58 64
     
    
    59 65
             self._log.info('Received blocking list: %s', blocked)
    
    60 66
             yield blocked
    
    ... ... @@ -121,9 +127,9 @@ def _make_unblock_request(jids):
    121 127
     def _parse_push(node):
    
    122 128
         items = node.getTags('item')
    
    123 129
         if not items:
    
    124
    -        return BlockingPush(block=[], unblock=[], unblock_all=True)
    
    130
    +        return BlockingPush(block=set(), unblock=set(), unblock_all=True)
    
    125 131
     
    
    126
    -    jids = []
    
    132
    +    jids = set()
    
    127 133
         for item in items:
    
    128 134
             jid = item.getAttr('jid')
    
    129 135
             if not jid:
    
    ... ... @@ -134,10 +140,10 @@ def _parse_push(node):
    134 140
             except Exception:
    
    135 141
                 continue
    
    136 142
     
    
    137
    -        jids.append(jid)
    
    143
    +        jids.add(jid)
    
    138 144
     
    
    139 145
     
    
    140
    -    block, unblock = [], []
    
    146
    +    block, unblock = set(), set()
    
    141 147
         if node.getName() == 'block':
    
    142 148
             block = jids
    
    143 149
         else:
    

  • nbxmpp/structs.py
    ... ... @@ -156,7 +156,7 @@ class RosterItem:
    156 156
             attrs['jid'] = jid
    
    157 157
     
    
    158 158
             groups = {group.getData() for group in node.getTags('group')}
    
    159
    -        attrs['groups'] = set(groups)
    
    159
    +        attrs['groups'] = groups
    
    160 160
     
    
    161 161
             return cls(**attrs)
    
    162 162