FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-94018: Remove trailing spaces in _sanitize_windows_name by Rygone · Pull Request #94040 · python/cpython · GitHub

Repository navigation

2 changes: 2 additions & 0 deletions Lib/test/test_zipfile.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -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,c<d>e|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 = [
Expand Down
4 changes: 2 additions & 2 deletions Lib/zipfile.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
:mod:`zipfile` will now remove trailing spaces from path components when extracting files on Windows.

Back | FazBrowse Home | New Git URL