From fb80d5b2673cf24435157c31ce61010de4fa5ff8 Mon Sep 17 00:00:00 2001 From: Christoph Gohlke Date: Fri, 27 Sep 2013 16:55:19 -0700 Subject: [PATCH] Circumvent classification of pngtest_bad.png as malware --- Tests/test_file_png.py | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/Tests/test_file_png.py b/Tests/test_file_png.py index 067ea5812..5ae726ad8 100644 --- a/Tests/test_file_png.py +++ b/Tests/test_file_png.py @@ -212,18 +212,14 @@ def test_roundtrip_text(): def test_scary(): # Check reading of evil PNG file. For information, see: # http://scary.beasts.org/security/CESA-2004-001.txt + # The first byte is removed from pngtest_bad.png + # to avoid classification as malware. - import base64 - file = "Tests/images/pngtest_bad.png.base64" - data = None + with open("Tests/images/pngtest_bad.png.bin", 'rb') as fd: + data = b'\x89' + fd.read() - if py3: - data = base64.decodebytes(open(file, 'rb').read()) - else: - data = base64.decodestring(open(file, 'rb').read()) - - file = BytesIO(data) - assert_exception(IOError, lambda: Image.open(file)) + pngfile = BytesIO(data) + assert_exception(IOError, lambda: Image.open(pngfile)) def test_trns_rgb(): # Check writing and reading of tRNS chunks for RGB images.