Skip to content

Commit 4e15b8d

Browse files
authored
gh-74453: Add stronger security warning to os.path.commonprefix (GH-144401)
1 parent 45d00a0 commit 4e15b8d

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

9898
.. function:: commonprefix(list, /)
9999

100-
Return the longest path prefix (taken character-by-character) that is a
101-
prefix of all paths in *list*. If *list* is empty, return the empty string
100+
Return the longest string prefix (taken character-by-character) that is a
101+
prefix of all strings in *list*. If *list* is empty, return the empty string
102102
(``''``).
103103

104-
.. note::
104+
.. warning::
105105

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

110112
::
111113

0 commit comments

Comments
 (0)