From c133713d334db804a21ff7a02edda0c8b32f6892 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Vinot?= Date: Sat, 12 Sep 2015 23:08:06 +0200 Subject: [PATCH] Fix bug in download sample function. Thanks to @kevthehermit --- pymisp/api.py | 14 +++++++------- setup.py | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/pymisp/api.py b/pymisp/api.py index 08d081a..1b8b83a 100644 --- a/pymisp/api.py +++ b/pymisp/api.py @@ -12,10 +12,7 @@ try: from urllib.parse import urljoin except ImportError: from urlparse import urljoin -try: - from io import StringIO -except ImportError: - from StringIO import StringIO +from io import BytesIO import zipfile import warnings import functools @@ -545,14 +542,17 @@ class PyMISP(object): return False, result.get('message') details = [] for f in result['result']: - zipped = StringIO(base64.b64decode(f['base64'])) + decoded = base64.b64decode(f['base64']) + #if not isinstance(decoded, unicode): + # decoded = decoded.encode('utf-8') + zipped = BytesIO(decoded) archive = zipfile.ZipFile(zipped) try: # New format - unzipped = StringIO(archive.open(f['md5'], pwd='infected').read()) + unzipped = BytesIO(archive.open(f['md5'], pwd='infected').read()) except KeyError: # Old format - unzipped = StringIO(archive.open(f['filename'], pwd='infected').read()) + unzipped = BytesIO(archive.open(f['filename'], pwd='infected').read()) details.append([f['event_id'], f['filename'], unzipped]) return True, details diff --git a/setup.py b/setup.py index 66794a7..2baeaa1 100644 --- a/setup.py +++ b/setup.py @@ -4,7 +4,7 @@ from setuptools import setup setup( name='pymisp', - version='1.8', + version='1.8.1', author='Raphaël Vinot', author_email='raphael.vinot@circl.lu', maintainer='Raphaël Vinot',