partly fix hmac usage
This commit is contained in:
parent
866b23650e
commit
11a357351d
|
@ -715,7 +715,7 @@ class Connection(CommonConnection, ConnectionHandlers):
|
|||
self.private_storage_supported = True
|
||||
self.privacy_rules_requested = False
|
||||
self.streamError = ''
|
||||
self.secret_hmac = str(random.random())[2:]
|
||||
self.secret_hmac = str(random.random())[2:].encode('utf-8')
|
||||
|
||||
self.sm = Smacks(self) # Stream Management
|
||||
|
||||
|
@ -2374,7 +2374,7 @@ class Connection(CommonConnection, ConnectionHandlers):
|
|||
|
||||
p = nbxmpp.Presence(to='%s/%s' % (room_jid, nick),
|
||||
show=show, status=self.status)
|
||||
h = hmac.new(self.secret_hmac, room_jid).hexdigest()[:6]
|
||||
h = hmac.new(self.secret_hmac, room_jid.encode('utf-8')).hexdigest()[:6]
|
||||
id_ = self.connection.getAnID()
|
||||
id_ = 'gajim_muc_' + id_ + '_' + h
|
||||
p.setID(id_)
|
||||
|
@ -2459,7 +2459,7 @@ class Connection(CommonConnection, ConnectionHandlers):
|
|||
xmpp_show = helpers.get_xmpp_show(show)
|
||||
p = nbxmpp.Presence(to='%s/%s' % (jid, nick), typ=ptype,
|
||||
show=xmpp_show, status=status)
|
||||
h = hmac.new(self.secret_hmac, jid).hexdigest()[:6]
|
||||
h = hmac.new(self.secret_hmac, jid.encode('utf-8')).hexdigest()[:6]
|
||||
id_ = self.connection.getAnID()
|
||||
id_ = 'gajim_muc_' + id_ + '_' + h
|
||||
p.setID(id_)
|
||||
|
|
|
@ -795,7 +795,8 @@ PresenceHelperEvent):
|
|||
and self.ptype == 'error':
|
||||
# Error presences may not include sent stanza, so we don't detect
|
||||
# it's a muc presence. So detect it by ID
|
||||
h = hmac.new(self.conn.secret_hmac, self.jid).hexdigest()[:6]
|
||||
h = hmac.new(self.conn.secret_hmac, self.jid.encode('utf-8')).\
|
||||
hexdigest()[:6]
|
||||
if self.id_.split('_')[-1] == h:
|
||||
self.is_gc = True
|
||||
self.status = self.stanza.getStatus() or ''
|
||||
|
|
Loading…
Reference in New Issue