]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-74453: Add stronger security warning to os.path.commonprefix (GH-144401)
authorSeth Michael Larson <seth@python.org>
Tue, 3 Feb 2026 14:07:59 +0000 (08:07 -0600)
committerGitHub <noreply@github.com>
Tue, 3 Feb 2026 14:07:59 +0000 (15:07 +0100)
Doc/library/os.path.rst

index 3cfe08a1fe1f7a968264e4768311fae1182d4148..bfd59fc5a82049d3cd4bc9962a354839fc47168a 100644 (file)
@@ -97,15 +97,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.
 
       ::