Merge pull request #2 from radarhere/fix_jpeg_magic_number

Updated _open check to match _accept
This commit is contained in:
Kirill Kuzminykh 2020-06-22 17:35:34 +03:00 committed by GitHub
commit b7b4aaceeb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -338,10 +338,11 @@ class JpegImageFile(ImageFile.ImageFile):
def _open(self):
s = self.fp.read(1)
s = self.fp.read(3)
if i8(s) != 255:
if s != b"\xFF\xD8\xFF":
raise SyntaxError("not a JPEG file")
s = b"\xFF"
# Create attributes
self.bits = self.layers = 0