Skip to content

Commit aae9ae0

Browse files
serhiy-storchakaSebastian Gassner
authored andcommitted
gh-146581: Update docs for dangerous filenames in ZIP files (GH-149994)
(cherry picked from commit ba0aca3) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com> Co-authored-by: Sebastian Gassner <sebastian.gassner@gmail.com>
1 parent 09b2e00 commit aae9ae0

2 files changed

Lines changed: 6 additions & 6 deletions

File tree

Doc/library/shutil.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -728,8 +728,8 @@ provided. They rely on the :mod:`zipfile` and :mod:`tarfile` modules.
728728

729729
Never extract archives from untrusted sources without prior inspection.
730730
It is possible that files are created outside of the path specified in
731-
the *extract_dir* argument, e.g. members that have absolute filenames
732-
starting with "/" or filenames with two dots "..".
731+
the *extract_dir* argument, for example, members that have absolute filenames
732+
or filenames with ".." components.
733733

734734
.. versionchanged:: 3.7
735735
Accepts a :term:`path-like object` for *filename* and *extract_dir*.

Doc/library/zipfile.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -374,9 +374,9 @@ ZipFile objects
374374
.. warning::
375375

376376
Never extract archives from untrusted sources without prior inspection.
377-
It is possible that files are created outside of *path*, e.g. members
378-
that have absolute filenames starting with ``"/"`` or filenames with two
379-
dots ``".."``. This module attempts to prevent that.
377+
It is possible that files are created outside of *path*, for example, members
378+
that have absolute filenames or filenames with ".." components.
379+
This module attempts to prevent that.
380380
See :meth:`extract` note.
381381

382382
.. versionchanged:: 3.6
@@ -547,7 +547,7 @@ Path objects
547547
The :class:`Path` class does not sanitize filenames within the ZIP archive. Unlike
548548
the :meth:`ZipFile.extract` and :meth:`ZipFile.extractall` methods, it is the
549549
caller's responsibility to validate or sanitize filenames to prevent path traversal
550-
vulnerabilities (e.g., filenames containing ".." or absolute paths). When handling
550+
vulnerabilities (for example, absolute paths or paths with ".." components). When handling
551551
untrusted archives, consider resolving filenames using :func:`os.path.abspath`
552552
and checking against the target directory with :func:`os.path.commonpath`.
553553

0 commit comments

Comments
 (0)