From e05612dc4842e92160e170b42122a059b967e1e4 Mon Sep 17 00:00:00 2001 From: Stiletto Date: Sun, 26 Jan 2014 16:47:51 +0400 Subject: [PATCH] Fix padding, larger avatar size limit --- bnw/xmpp/iq_handlers.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/bnw/xmpp/iq_handlers.py b/bnw/xmpp/iq_handlers.py index 2e37adfc..2bc15960 100644 --- a/bnw/xmpp/iq_handlers.py +++ b/bnw/xmpp/iq_handlers.py @@ -46,11 +46,14 @@ def get_and_resize_avatar(iq): if not filedata: return filedata = str(filedata) - if len(filedata) > 32768: + if len(filedata) > 102400: # XEP-0153 says what image SHOULD be 8KB max, - # let's approve up to 32KB. + # let's approve up to 100KB. return try: + missing_padding = 4 - len(filedata) % 4 + if missing_padding: + filedata += '=' * missing_padding avatar = base64.b64decode(filedata) except TypeError: return