diff --git a/src/PIL/IcnsImagePlugin.py b/src/PIL/IcnsImagePlugin.py index 069aff96b63..c22bfe0ed06 100644 --- a/src/PIL/IcnsImagePlugin.py +++ b/src/PIL/IcnsImagePlugin.py @@ -167,7 +167,7 @@ def __init__(self, fobj): self.dct = dct = {} self.fobj = fobj sig, filesize = nextheader(fobj) - if sig != MAGIC: + if not _accept(sig): raise SyntaxError("not an icns file") i = HEADERSIZE while i < filesize: diff --git a/src/PIL/TiffImagePlugin.py b/src/PIL/TiffImagePlugin.py index 35ff1c1bbf7..d8dc1741a3b 100644 --- a/src/PIL/TiffImagePlugin.py +++ b/src/PIL/TiffImagePlugin.py @@ -493,7 +493,7 @@ def __init__(self, ifh=b"II\052\0\0\0\0\0", prefix=None, group=None): endianness. :param prefix: Override the endianness of the file. """ - if ifh[:4] not in PREFIXES: + if not _accept(ifh): raise SyntaxError(f"not a TIFF file (header {repr(ifh)} not valid)") self._prefix = prefix if prefix is not None else ifh[:2] if self._prefix == MM: