From 0959162bfd70de7a6f51ba05b1cb764ce55bfa91 Mon Sep 17 00:00:00 2001 From: Tim Hatch Date: Mon, 20 Feb 2023 09:07:03 -0800 Subject: [PATCH] gh-88233: zipfile: handle extras after a zip64 extra (GH-96161) Previously, any data _after_ the zip64 extra would be removed. With many new tests. Fixes GH-88233 (cherry picked from commit 59e86caca812fc993c5eb7dc8ccd1508ffccba86) Co-authored-by: Tim Hatch Automerge-Triggered-By: GH:jaraco --- Lib/test/test_zipfile.py | 62 +++++++++++++++++++ Lib/zipfile.py | 2 + ...2-09-05-12-17-34.gh-issue-88233.gff9qJ.rst | 2 + 3 files changed, 66 insertions(+) create mode 100644 Misc/NEWS.d/next/Library/2022-09-05-12-17-34.gh-issue-88233.gff9qJ.rst diff --git a/Lib/test/test_zipfile.py b/Lib/test/test_zipfile.py index cf40412f85266d..d591b892306196 100644 --- a/Lib/test/test_zipfile.py +++ b/Lib/test/test_zipfile.py @@ -3210,5 +3210,67 @@ def test_inheritance(self, alpharep): assert isinstance(file, cls) +class StripExtraTests(unittest.TestCase): + # Note: all of the "z" characters are technically invalid, but up + # to 3 bytes at the end of the extra will be passed through as they + # are too short to encode a valid extra. + + ZIP64_EXTRA = 1 + + def test_no_data(self): + s = struct.Struct("