sha is now computed on the raw image data and not the base64 encoded data

This commit is contained in:
Yann Leboulanger 2005-12-05 08:45:39 +00:00
parent 5260f38ea8
commit ed47580227
1 changed files with 5 additions and 6 deletions

View File

@ -35,6 +35,7 @@ import socket
import random
random.seed()
import signal
import base64
if os.name != 'nt':
signal.signal(signal.SIGPIPE, signal.SIG_DFL)
@ -267,7 +268,8 @@ class Connection:
if vcard.has_key('PHOTO') and isinstance(vcard['PHOTO'], dict) and \
vcard['PHOTO'].has_key('BINVAL'):
photo = vcard['PHOTO']['BINVAL']
avatar_sha = sha.sha(photo).hexdigest()
photo_decoded = base64.decodestring(photo)
avatar_sha = sha.sha(photo_decoded).hexdigest()
else:
avatar_sha = ''
@ -2127,11 +2129,8 @@ class Connection:
if vcard.has_key('PHOTO') and isinstance(vcard['PHOTO'], dict) and \
vcard['PHOTO'].has_key('BINVAL'):
photo = vcard['PHOTO']['BINVAL']
avatar_sha = sha.sha(photo).hexdigest()
else:
avatar_sha = ''
if avatar_sha:
photo_decoded = base64.decodestring(photo)
avatar_sha = sha.sha(photo_decoded).hexdigest()
iq2.getTag('PHOTO').setTagData('SHA', avatar_sha)
self.awaiting_answers[id] = (VCARD_PUBLISHED, iq2)