Skip to content

Commit

Permalink
Merge pull request #2 from radarhere/fix_jpeg_magic_number
Browse files Browse the repository at this point in the history
Updated _open check to match _accept
  • Loading branch information
Cykooz authored Jun 22, 2020
2 parents 6d2fe42 + 96d1a8b commit b7b4aac
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/PIL/JpegImagePlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit b7b4aac

Please sign in to comment.