@@ -2428,6 +2428,10 @@ def test_decompress_without_3rd_party_library(self):
24282428
24292429 @requires_zlib ()
24302430 def test_full_overlap_different_names (self ):
2431+ # The ZIP file contains two central directory entries with
2432+ # different names which refer to the same local header.
2433+ # The name of the local header matches the name of the first
2434+ # central directory entry.
24312435 data = (
24322436 b'PK\x03 \x04 \x14 \x00 \x00 \x00 \x08 \x00 \xa0 lH\x05 \xe2 \x1e '
24332437 b'8\xbb \x10 \x00 \x00 \x00 \t \x04 \x00 \x00 \x01 \x00 \x00 \x00 b\xed '
@@ -2457,6 +2461,10 @@ def test_full_overlap_different_names(self):
24572461
24582462 @requires_zlib ()
24592463 def test_full_overlap_different_names2 (self ):
2464+ # The ZIP file contains two central directory entries with
2465+ # different names which refer to the same local header.
2466+ # The name of the local header matches the name of the second
2467+ # central directory entry.
24602468 data = (
24612469 b'PK\x03 \x04 \x14 \x00 \x00 \x00 \x08 \x00 \xa0 lH\x05 \xe2 \x1e '
24622470 b'8\xbb \x10 \x00 \x00 \x00 \t \x04 \x00 \x00 \x01 \x00 \x00 \x00 a\xed '
@@ -2488,6 +2496,8 @@ def test_full_overlap_different_names2(self):
24882496
24892497 @requires_zlib ()
24902498 def test_full_overlap_same_name (self ):
2499+ # The ZIP file contains two central directory entries with
2500+ # the same name which refer to the same local header.
24912501 data = (
24922502 b'PK\x03 \x04 \x14 \x00 \x00 \x00 \x08 \x00 \xa0 lH\x05 \xe2 \x1e '
24932503 b'8\xbb \x10 \x00 \x00 \x00 \t \x04 \x00 \x00 \x01 \x00 \x00 \x00 a\xed '
@@ -2520,6 +2530,8 @@ def test_full_overlap_same_name(self):
25202530
25212531 @requires_zlib ()
25222532 def test_quoted_overlap (self ):
2533+ # The ZIP file contains two files. The second local header
2534+ # is contained in the range of the first file.
25232535 data = (
25242536 b'PK\x03 \x04 \x14 \x00 \x00 \x00 \x08 \x00 \xa0 lH\x05 Y\xfc '
25252537 b'8\x04 4\x00 \x00 \x00 (\x04 \x00 \x00 \x01 \x00 \x00 \x00 a\x00 '
@@ -2551,6 +2563,7 @@ def test_quoted_overlap(self):
25512563
25522564 @requires_zlib ()
25532565 def test_overlap_with_central_dir (self ):
2566+ # The local header offset is equal to the central directory offset.
25542567 data = (
25552568 b'PK\x01 \x02 \x14 \x03 \x14 \x00 \x00 \x00 \x08 \x00 G_|Z'
25562569 b'\xe2 \x1e 8\xbb \x0b \x00 \x00 \x00 \t \x04 \x00 \x00 \x01 \x00 \x00 \x00 '
@@ -2565,11 +2578,15 @@ def test_overlap_with_central_dir(self):
25652578 self .assertEqual (zi .header_offset , 0 )
25662579 self .assertEqual (zi .compress_size , 11 )
25672580 self .assertEqual (zi .file_size , 1033 )
2581+ # Found central directory signature PK\x01\x02 instead of
2582+ # local header signature PK\x03\x04.
25682583 with self .assertRaisesRegex (zipfile .BadZipFile , 'Bad magic number' ):
25692584 zipf .read ('a' )
25702585
25712586 @requires_zlib ()
25722587 def test_overlap_with_archive_comment (self ):
2588+ # The local header is written after the central directory,
2589+ # in the archive comment.
25732590 data = (
25742591 b'PK\x01 \x02 \x14 \x03 \x14 \x00 \x00 \x00 \x08 \x00 G_|Z'
25752592 b'\xe2 \x1e 8\xbb \x0b \x00 \x00 \x00 \t \x04 \x00 \x00 \x01 \x00 \x00 \x00 '
0 commit comments