mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-02-03 05:04:24 +03:00
Fixed _binary handling in _accept methods
This commit is contained in:
parent
1f9f9cc206
commit
4c02ae4061
|
@ -33,7 +33,7 @@ i32 = _binary.i32le
|
|||
|
||||
|
||||
def _accept(prefix):
|
||||
return i32(prefix) == MAGIC
|
||||
return len(prefix) >= 4 and i32(prefix) == MAGIC
|
||||
|
||||
|
||||
##
|
||||
|
|
|
@ -187,7 +187,7 @@ class PSFile(object):
|
|||
|
||||
|
||||
def _accept(prefix):
|
||||
return prefix[:4] == b"%!PS" or i32(prefix) == 0xC6D3D0C5
|
||||
return prefix[:4] == b"%!PS" or (len(prefix) >= 4 and i32(prefix) == 0xC6D3D0C5)
|
||||
|
||||
##
|
||||
# Image plugin for Encapsulated Postscript. This plugin supports only
|
||||
|
|
|
@ -30,7 +30,7 @@ o8 = _binary.o8
|
|||
# decoder
|
||||
|
||||
def _accept(prefix):
|
||||
return i16(prefix[4:6]) in [0xAF11, 0xAF12]
|
||||
return len(prefix) >= 6 and i16(prefix[4:6]) in [0xAF11, 0xAF12]
|
||||
|
||||
|
||||
##
|
||||
|
|
|
@ -19,7 +19,7 @@ i32 = _binary.i32be
|
|||
|
||||
|
||||
def _accept(prefix):
|
||||
return i32(prefix) >= 20 and i32(prefix[4:8]) == 1
|
||||
return len(prefix) >= 8 and i32(prefix) >= 20 and i32(prefix[4:8]) == 1
|
||||
|
||||
|
||||
##
|
||||
|
|
|
@ -29,7 +29,7 @@ i32 = _binary.i32be
|
|||
|
||||
|
||||
def _accept(prefix):
|
||||
return i16(prefix) == 474
|
||||
return len(prefix) >= 2 and i16(prefix) == 474
|
||||
|
||||
|
||||
##
|
||||
|
|
|
@ -27,7 +27,7 @@ i32 = _binary.i32be
|
|||
|
||||
|
||||
def _accept(prefix):
|
||||
return i32(prefix) == 0x59a66a95
|
||||
return len(prefix) >= 4 and i32(prefix) == 0x59a66a95
|
||||
|
||||
|
||||
##
|
||||
|
|
Loading…
Reference in New Issue
Block a user