Skip to content

Commit 445398b

Browse files
committed
Scanning until the last slash and removing it only if needed
1 parent 348a679 commit 445398b

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

Lib/zipfile.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -510,7 +510,9 @@ def from_file(cls, filename, arcname=None, *, strict_timestamps=True):
510510
if arcname is None:
511511
arcname = filename
512512
arcname = os.path.normpath(os.path.splitdrive(arcname)[1])
513-
while arcname[0] in (os.sep, os.altsep):
513+
while arcname[0] in (os.sep, os.altsep) and arcname[1] in (os.sep, os.altsep):
514+
arcname = arcname[1:]
515+
if arcname[0] in (os.sep, os.altsep) and os.sep not in arcname[1:]:
514516
arcname = arcname[1:]
515517
if isdir:
516518
arcname += '/'

0 commit comments

Comments
 (0)