Skip to content

Commit 11a1e4e

Browse files
[3.11] gh-74453: Add stronger security warning to os.path.commonprefix
gh-74453: Add stronger security warning to os.path.commonprefix (GH-144401) (cherry picked from commit 4e15b8d) Co-authored-by: Seth Michael Larson <seth@python.org>
1 parent afc40bd commit 11a1e4e

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

Doc/library/os.path.rst

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -95,15 +95,17 @@ the :mod:`glob` module.)
9595

9696
.. function:: commonprefix(list)
9797

98-
Return the longest path prefix (taken character-by-character) that is a
99-
prefix of all paths in *list*. If *list* is empty, return the empty string
98+
Return the longest string prefix (taken character-by-character) that is a
99+
prefix of all strings in *list*. If *list* is empty, return the empty string
100100
(``''``).
101101

102-
.. note::
102+
.. warning::
103103

104104
This function may return invalid paths because it works a
105-
character at a time. To obtain a valid path, see
106-
:func:`commonpath`.
105+
character at a time.
106+
If you need a **common path prefix**, then the algorithm
107+
implemented in this function is not secure. Use
108+
:func:`commonpath` for finding a common path prefix.
107109

108110
::
109111

0 commit comments

Comments
 (0)