crash when avatar have incorrect padding
I use gajim 0.9.1 from debian testing.
I have :
Traceback (most recent call last):
File "/usr/share/gajim/src/common/connection.py", line 2395, in process
self.connection.Process(timeout)
File "/usr/share/gajim/src/common/xmpp/dispatcher.py", line 292, in dispatch
handler['func'](session,stanza)
File "/usr/share/gajim/src/common/connection.py", line 280, in _vCardCB
photo_decoded = base64.decodestring(photo)
File "/usr/lib/python2.3/base64.py", line 44, in decodestring
return binascii.a2b_base64(s)
Error: Incorrect padding
It seems I have a buddy with an avatar incorrectly encodded. The solution seems to catch the exception raised by base64.decodestring. A little patch that seems to fix the problem on my box (that's the first time I use python):
--- /usr/share/gajim/src/common/connection.py.save 2006-04-07 16:38:23.000000000 +0200
+++ /usr/share/gajim/src/common/connection.py 2006-04-07 17:24:33.000000000 +0200
@@ -275,9 +275,13 @@
vcard = self.node_to_dict(card)
if vcard.has_key('PHOTO') and isinstance(vcard['PHOTO'], dict) and \
vcard['PHOTO'].has_key('BINVAL'):
- photo = vcard['PHOTO']['BINVAL']
- photo_decoded = base64.decodestring(photo)
- avatar_sha = sha.sha(photo_decoded).hexdigest()
+ try:
+ photo = vcard['PHOTO']['BINVAL']
+ photo_decoded = base64.decodestring(photo)
+ avatar_sha = sha.sha(photo_decoded).hexdigest()
+ except:
+ print "Error decoding avatar"
+ avatar_sha = ''
else:
avatar_sha = ''
I let you adapt for the SVN trunk.