From ed475802276bab16c4772c1478cdfecdd6c6847e Mon Sep 17 00:00:00 2001 From: Yann Leboulanger Date: Mon, 5 Dec 2005 08:45:39 +0000 Subject: [PATCH] sha is now computed on the raw image data and not the base64 encoded data --- src/common/connection.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/common/connection.py b/src/common/connection.py index 10bf46615..c23817777 100644 --- a/src/common/connection.py +++ b/src/common/connection.py @@ -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)