mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-05-30 10:43:16 +03:00
Circumvent classification of pngtest_bad.png as malware
This commit is contained in:
parent
ada10a0ba4
commit
fb80d5b267
|
@ -212,18 +212,14 @@ def test_roundtrip_text():
|
||||||
def test_scary():
|
def test_scary():
|
||||||
# Check reading of evil PNG file. For information, see:
|
# Check reading of evil PNG file. For information, see:
|
||||||
# http://scary.beasts.org/security/CESA-2004-001.txt
|
# 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
|
with open("Tests/images/pngtest_bad.png.bin", 'rb') as fd:
|
||||||
file = "Tests/images/pngtest_bad.png.base64"
|
data = b'\x89' + fd.read()
|
||||||
data = None
|
|
||||||
|
|
||||||
if py3:
|
pngfile = BytesIO(data)
|
||||||
data = base64.decodebytes(open(file, 'rb').read())
|
assert_exception(IOError, lambda: Image.open(pngfile))
|
||||||
else:
|
|
||||||
data = base64.decodestring(open(file, 'rb').read())
|
|
||||||
|
|
||||||
file = BytesIO(data)
|
|
||||||
assert_exception(IOError, lambda: Image.open(file))
|
|
||||||
|
|
||||||
def test_trns_rgb():
|
def test_trns_rgb():
|
||||||
# Check writing and reading of tRNS chunks for RGB images.
|
# Check writing and reading of tRNS chunks for RGB images.
|
||||||
|
|
Loading…
Reference in New Issue
Block a user