changeset 3a5a87ebcc0b in /home/hg/repos/gajim
details:http://hg.gajim.org/gajim?cmd=changeset;node=3a5a87ebcc0b description: partly fix hmac usage
diffstat:
src/common/connection.py | 6 +++--- src/common/connection_handlers_events.py | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-)
diffs (43 lines):
diff -r df54e4a483f1 -r 3a5a87ebcc0b src/common/connection.py --- a/src/common/connection.py Thu Jan 03 21:34:19 2013 +0400 +++ b/src/common/connection.py Thu Jan 03 19:01:18 2013 +0100 @@ -715,7 +715,7 @@ 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 @@
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 @@ 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_) diff -r df54e4a483f1 -r 3a5a87ebcc0b src/common/connection_handlers_events.py --- a/src/common/connection_handlers_events.py Thu Jan 03 21:34:19 2013 +0400 +++ b/src/common/connection_handlers_events.py Thu Jan 03 19:01:18 2013 +0100 @@ -795,7 +795,8 @@ 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 ''