Skip to content

Commit 276b9f2

Browse files
[3.12] 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 a76e4cd commit 276b9f2

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
@@ -93,15 +93,17 @@ the :mod:`glob` module.)
9393

9494
.. function:: commonprefix(list)
9595

96-
Return the longest path prefix (taken character-by-character) that is a
97-
prefix of all paths in *list*. If *list* is empty, return the empty string
96+
Return the longest string prefix (taken character-by-character) that is a
97+
prefix of all strings in *list*. If *list* is empty, return the empty string
9898
(``''``).
9999

100-
.. note::
100+
.. warning::
101101

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

106108
::
107109

0 commit comments

Comments
 (0)