summaryrefslogtreecommitdiffstats
path: root/Lib/zipfile
diff options
context:
space:
mode:
authorCarey Metcalfe <carey@cmetcalfe.ca>2023-05-11 07:25:16 (GMT)
committerGitHub <noreply@github.com>2023-05-11 07:25:16 (GMT)
commit4abfe6a14b5be5decbaa3142d9e2549cf2d86c34 (patch)
tree8935ca48a59633aaa5e4a29fae8d7eca949e1901 /Lib/zipfile
parentfcd5fb49b1d71165f3c503c3d2e74a082ddb2f21 (diff)
downloadcpython-4abfe6a14b5be5decbaa3142d9e2549cf2d86c34.zip
cpython-4abfe6a14b5be5decbaa3142d9e2549cf2d86c34.tar.gz
cpython-4abfe6a14b5be5decbaa3142d9e2549cf2d86c34.tar.bz2
GH-92184: Convert os.altsep to '/' in filenames when creating ZipInfo objects (#92185)
This causes the zipfile module to also consider the character defined by `os.altsep` (if there is one) to be a path separator and convert it to a forward slash, as defined by the zip specification. A logical no-op on all known platforms today as os.altsep is currently only set to a meaningful value on Windows (where it is "/").
Diffstat (limited to 'Lib/zipfile')
-rw-r--r--Lib/zipfile/__init__.py2
1 files changed, 2 insertions, 0 deletions
diff --git a/Lib/zipfile/__init__.py b/Lib/zipfile/__init__.py
index 95c0479..116b939 100644
--- a/Lib/zipfile/__init__.py
+++ b/Lib/zipfile/__init__.py
@@ -352,6 +352,8 @@ def _sanitize_filename(filename):
# ZIP format specification.
if os.sep != "/" and os.sep in filename:
filename = filename.replace(os.sep, "/")
+ if os.altsep and os.altsep != "/" and os.altsep in filename:
+ filename = filename.replace(os.altsep, "/")
return filename