Fix bug in download sample function.

Thanks to @kevthehermit
pull/2/merge v1.8.1
Raphaël Vinot 2015-09-12 23:08:06 +02:00
parent 22e4d58a50
commit c133713d33
2 changed files with 8 additions and 8 deletions

View File

@ -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

View File

@ -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',