diff --git a/tests/test_restofworld_index.py b/tests/test_restofworld_index.py index 6b109d252..acbd87dc9 100644 --- a/tests/test_restofworld_index.py +++ b/tests/test_restofworld_index.py @@ -260,6 +260,17 @@ class ArchiveTest(unittest.TestCase): self.assertEqual((row["signature"], row["count"], row["detail"]), ("psin", 2, "tags=LSCH,CHKS;field8=22;complete=1")) + def test_text_is_judged_on_the_same_512_bytes_as_a_carved_file(self): + # _printable samples 512 bytes. The archive scan kept only 256, so a stream whose first 306 bytes are + # printable read as text from an archive and as raw from its carved file. + data = b"name=" + b"a" * 301 + bytes(range(256)) + bytes(44) + rpf = os.path.join(self.root, "text_head.rpf") + with open(rpf, "wb") as f: + f.write(b"9FPR" + struct.pack(" max_inflate: too_big = True break - if len(head) < 256: - head += chunk[:256 - len(head)] + if len(head) < 512: # _printable samples 512 bytes, as from a carved file + head += chunk[:512 - len(head)] if keep_body: if len(head) >= 16: is_psin = head[:4] == b"PSIN"