Skip to content

Commit 5704727

Browse files
committed
Add stronger security warning to os.path.commonprefix
1 parent a447828 commit 5704727

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

Doc/library/os.path.rst

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,12 +97,15 @@ 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+
.. danger::
105105

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.
106109
This function may return invalid paths because it works a
107110
character at a time. To obtain a valid path, see
108111
:func:`commonpath`.

0 commit comments

Comments
 (0)