From d1fe8599d6ad6055a877640df55582ff17f6166e Mon Sep 17 00:00:00 2001 From: Robin Plumey <44498456+Rygone@users.noreply.github.com> Date: Mon, 20 Jun 2022 22:32:55 +0200 Subject: [PATCH 1/7] hg-94018: Remove trailing spaces in _sanitize_windows_name --- Lib/zipfile.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Lib/zipfile.py b/Lib/zipfile.py index fc6ca65e5ed1e9..e3b7a61a6399be 100644 --- a/Lib/zipfile.py +++ b/Lib/zipfile.py @@ -1685,8 +1685,8 @@ def _sanitize_windows_name(cls, arcname, pathsep): table = str.maketrans(illegal, '_' * len(illegal)) cls._windows_illegal_name_trans_table = table arcname = arcname.translate(table) - # remove trailing dots - arcname = (x.rstrip('.') for x in arcname.split(pathsep)) + # remove trailing dots and spaces + arcname = (x.rstrip(' .') for x in arcname.split(pathsep)) # rejoin, removing empty parts. arcname = pathsep.join(x for x in arcname if x) return arcname From ef6e34f93a3711a7724823c4f644be38f05ff1d7 Mon Sep 17 00:00:00 2001 From: "blurb-it[bot]" <43283697+blurb-it[bot]@users.noreply.github.com> Date: Mon, 20 Jun 2022 22:32:15 +0000 Subject: [PATCH 2/7] =?UTF-8?q?=F0=9F=93=9C=F0=9F=A4=96=20Added=20by=20blu?= =?UTF-8?q?rb=5Fit.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../next/Windows/2022-06-20-22-32-14.gh-issue-94018.bycC3A.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 Misc/NEWS.d/next/Windows/2022-06-20-22-32-14.gh-issue-94018.bycC3A.rst diff --git a/Misc/NEWS.d/next/Windows/2022-06-20-22-32-14.gh-issue-94018.bycC3A.rst b/Misc/NEWS.d/next/Windows/2022-06-20-22-32-14.gh-issue-94018.bycC3A.rst new file mode 100644 index 00000000000000..1561553ec54cb3 --- /dev/null +++ b/Misc/NEWS.d/next/Windows/2022-06-20-22-32-14.gh-issue-94018.bycC3A.rst @@ -0,0 +1 @@ +Remove trailing spaces in Lib.zipfile._sanitize_windows_name() From 65777a17fdec7c1e3d433deeb8e8b33159f329c9 Mon Sep 17 00:00:00 2001 From: Robin Plumey <44498456+Rygone@users.noreply.github.com> Date: Tue, 21 Jun 2022 00:39:14 +0200 Subject: [PATCH 3/7] Update 2022-06-20-22-32-14.gh-issue-94018.bycC3A.rst --- .../next/Windows/2022-06-20-22-32-14.gh-issue-94018.bycC3A.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Misc/NEWS.d/next/Windows/2022-06-20-22-32-14.gh-issue-94018.bycC3A.rst b/Misc/NEWS.d/next/Windows/2022-06-20-22-32-14.gh-issue-94018.bycC3A.rst index 1561553ec54cb3..640f9b8cdf3dba 100644 --- a/Misc/NEWS.d/next/Windows/2022-06-20-22-32-14.gh-issue-94018.bycC3A.rst +++ b/Misc/NEWS.d/next/Windows/2022-06-20-22-32-14.gh-issue-94018.bycC3A.rst @@ -1 +1 @@ -Remove trailing spaces in Lib.zipfile._sanitize_windows_name() +Remove trailing spaces in :func:`Lib.zipfile._sanitize_windows_name` From 29f57ee3f894b920266d0e7ab6784baff72651a0 Mon Sep 17 00:00:00 2001 From: Robin Plumey <44498456+Rygone@users.noreply.github.com> Date: Tue, 21 Jun 2022 00:52:59 +0200 Subject: [PATCH 4/7] Update Misc/NEWS.d/next/Windows/2022-06-20-22-32-14.gh-issue-94018.bycC3A.rst Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com> --- .../next/Windows/2022-06-20-22-32-14.gh-issue-94018.bycC3A.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Misc/NEWS.d/next/Windows/2022-06-20-22-32-14.gh-issue-94018.bycC3A.rst b/Misc/NEWS.d/next/Windows/2022-06-20-22-32-14.gh-issue-94018.bycC3A.rst index 640f9b8cdf3dba..c13d73ab369e46 100644 --- a/Misc/NEWS.d/next/Windows/2022-06-20-22-32-14.gh-issue-94018.bycC3A.rst +++ b/Misc/NEWS.d/next/Windows/2022-06-20-22-32-14.gh-issue-94018.bycC3A.rst @@ -1 +1 @@ -Remove trailing spaces in :func:`Lib.zipfile._sanitize_windows_name` +Remove trailing spaces in :func:`zipfile._sanitize_windows_name` From 1b35fc182fa5618ce4f93eabaed084751c0af62a Mon Sep 17 00:00:00 2001 From: Robin Plumey <44498456+Rygone@users.noreply.github.com> Date: Tue, 21 Jun 2022 22:46:46 +0200 Subject: [PATCH 5/7] Update Misc/NEWS.d/next/Windows/2022-06-20-22-32-14.gh-issue-94018.bycC3A.rst Co-authored-by: Zachary Ware --- .../next/Windows/2022-06-20-22-32-14.gh-issue-94018.bycC3A.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Misc/NEWS.d/next/Windows/2022-06-20-22-32-14.gh-issue-94018.bycC3A.rst b/Misc/NEWS.d/next/Windows/2022-06-20-22-32-14.gh-issue-94018.bycC3A.rst index c13d73ab369e46..e9a32c0db80c6c 100644 --- a/Misc/NEWS.d/next/Windows/2022-06-20-22-32-14.gh-issue-94018.bycC3A.rst +++ b/Misc/NEWS.d/next/Windows/2022-06-20-22-32-14.gh-issue-94018.bycC3A.rst @@ -1 +1 @@ -Remove trailing spaces in :func:`zipfile._sanitize_windows_name` +:mod:`zipfile` will now remove trailing spaces from path components on extraction. From ba39a9b38f50a3c25d7c0bb85a3c8ef460b74266 Mon Sep 17 00:00:00 2001 From: Rygone <44498456+Rygone@users.noreply.github.com> Date: Thu, 23 Jun 2022 16:36:35 +0200 Subject: [PATCH 6/7] Update test_zipfile.py --- Lib/test/test_zipfile.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Lib/test/test_zipfile.py b/Lib/test/test_zipfile.py index f4c11d88c8a09f..fa0ca5aa7428ac 100644 --- a/Lib/test/test_zipfile.py +++ b/Lib/test/test_zipfile.py @@ -1440,6 +1440,8 @@ def test_sanitize_windows_name(self): self.assertEqual(san(r',,?,C:,foo,bar/z', ','), r'_,C_,foo,bar/z') self.assertEqual(san(r'a\b,ce|f"g?h*i', ','), r'a\b,c_d_e_f_g_h_i') self.assertEqual(san('../../foo../../ba..r', '/'), r'foo/ba..r') + self.assertEqual(san(' / /foo / /ba r', '/'), r'foo/ba r') + self.assertEqual(san(' . /. /foo ./ . /. ./ba .r', '/'), r'foo/ba .r') def test_extract_hackers_arcnames_common_cases(self): common_hacknames = [ From 2a2e53e2d37646911d9b61af58bdd052cb834dce Mon Sep 17 00:00:00 2001 From: Robin Plumey <44498456+Rygone@users.noreply.github.com> Date: Fri, 24 Jun 2022 00:18:36 +0200 Subject: [PATCH 7/7] Update Misc/NEWS.d/next/Windows/2022-06-20-22-32-14.gh-issue-94018.bycC3A.rst Co-authored-by: Sam Ezeh --- .../next/Windows/2022-06-20-22-32-14.gh-issue-94018.bycC3A.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Misc/NEWS.d/next/Windows/2022-06-20-22-32-14.gh-issue-94018.bycC3A.rst b/Misc/NEWS.d/next/Windows/2022-06-20-22-32-14.gh-issue-94018.bycC3A.rst index e9a32c0db80c6c..a2e558b3b4b3af 100644 --- a/Misc/NEWS.d/next/Windows/2022-06-20-22-32-14.gh-issue-94018.bycC3A.rst +++ b/Misc/NEWS.d/next/Windows/2022-06-20-22-32-14.gh-issue-94018.bycC3A.rst @@ -1 +1 @@ -:mod:`zipfile` will now remove trailing spaces from path components on extraction. +:mod:`zipfile` will now remove trailing spaces from path components when extracting files on Windows.