[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 4e15b8d95d)

Co-authored-by: Seth Michael Larson <seth@python.org>
This commit is contained in:
Miss Islington (bot) 2026-02-03 15:29:02 +01:00 committed by GitHub
parent a76e4cd62d
commit 276b9f2ea2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -93,15 +93,17 @@ the :mod:`glob` module.)
.. function:: commonprefix(list)
Return the longest path prefix (taken character-by-character) that is a
prefix of all paths in *list*. If *list* is empty, return the empty string
Return the longest string prefix (taken character-by-character) that is a
prefix of all strings in *list*. If *list* is empty, return the empty string
(``''``).
.. note::
.. warning::
This function may return invalid paths because it works a
character at a time. To obtain a valid path, see
:func:`commonpath`.
character at a time.
If you need a **common path prefix**, then the algorithm
implemented in this function is not secure. Use
:func:`commonpath` for finding a common path prefix.
::