diff --git a/polyfile/magic.py b/polyfile/magic.py index a0ecb87..02650eb 100644 --- a/polyfile/magic.py +++ b/polyfile/magic.py @@ -2600,7 +2600,7 @@ def test(self, data: bytes, absolute_offset: int, parent_match: Optional[TestRes detector.feed(data[offset:offset+1024]) offset += 1024 detector.close() - if detector.result["confidence"] >= self.minimum_encoding_confidence: + if detector.result["confidence"] >= self.minimum_encoding_confidence and detector.result["encoding"] is not None: encoding = detector.result["encoding"] try: value = data[absolute_offset:].decode(encoding)