Merge 408cec404a into 877527cefc
This commit is contained in:
commit
b06e291429
@ -124,6 +124,14 @@ class TestFilePng:
|
||||
with Image.open(test_file):
|
||||
pass
|
||||
|
||||
def test_ihdr_unknown_mode(self) -> None:
|
||||
fp = BytesIO(chunk(b"IHDR", b"\x00" * 13))
|
||||
with PngImagePlugin.PngStream(fp) as png:
|
||||
cid, pos, length = png.read()
|
||||
png.call(cid, pos, length)
|
||||
|
||||
assert png.im_mode == ""
|
||||
|
||||
def test_bad_text(self) -> None:
|
||||
# Make sure PIL can read malformed tEXt chunks (@PIL152)
|
||||
|
||||
|
||||
@ -400,6 +400,9 @@ class PngStream(ChunkStream):
|
||||
|
||||
self.text_memory = 0
|
||||
|
||||
def __enter__(self) -> PngStream:
|
||||
return self
|
||||
|
||||
def check_text_memory(self, chunklen: int) -> None:
|
||||
self.text_memory += chunklen
|
||||
if self.text_memory > MAX_TEXT_MEMORY:
|
||||
@ -461,7 +464,7 @@ class PngStream(ChunkStream):
|
||||
self.im_size = i32(s, 0), i32(s, 4)
|
||||
try:
|
||||
self.im_mode, self.im_rawmode = _MODES[(s[8], s[9])]
|
||||
except Exception:
|
||||
except KeyError:
|
||||
pass
|
||||
if s[12]:
|
||||
self.im_info["interlace"] = 1
|
||||
|
||||
Loading…
Reference in New Issue
Block a user