From 00e971710a09c835a06e1268c174b720fc0aa53a Mon Sep 17 00:00:00 2001 From: Dustin Ingram Date: Thu, 21 Aug 2025 17:40:45 +0000 Subject: [PATCH 1/3] Correct regex for metadata 'name' format The current regex permits strings that end in the newline character, which is counter to what the description for the field states ("ASCII letters and numbers, period, underscore and hyphen"). This updates the rexex to use `\Z` instead of `$` to match at the end of the string and exclude newline characters. --- source/specifications/name-normalization.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/specifications/name-normalization.rst b/source/specifications/name-normalization.rst index ba3246b63..e295a3d11 100644 --- a/source/specifications/name-normalization.rst +++ b/source/specifications/name-normalization.rst @@ -17,7 +17,7 @@ underscore and hyphen. It must start and end with a letter or number. This means that valid project names are limited to those which match the following regex (run with :py:data:`re.IGNORECASE`):: - ^([A-Z0-9]|[A-Z0-9][A-Z0-9._-]*[A-Z0-9])$ + ^([A-Z0-9]|[A-Z0-9][A-Z0-9._-]*[A-Z0-9])\Z .. _name-normalization: From fb63fa51d867197d98888d7978dba10449374b67 Mon Sep 17 00:00:00 2001 From: Dustin Ingram Date: Thu, 21 Aug 2025 17:53:46 +0000 Subject: [PATCH 2/3] Update regex from PEP 508 as well --- source/specifications/dependency-specifiers.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/specifications/dependency-specifiers.rst b/source/specifications/dependency-specifiers.rst index 06897da27..168d966d4 100644 --- a/source/specifications/dependency-specifiers.rst +++ b/source/specifications/dependency-specifiers.rst @@ -142,7 +142,7 @@ document we limit the acceptable values for identifiers to that regex. A full redefinition of name may take place in a future metadata PEP. The regex (run with re.IGNORECASE) is:: - ^([A-Z0-9]|[A-Z0-9][A-Z0-9._-]*[A-Z0-9])$ + ^([A-Z0-9]|[A-Z0-9][A-Z0-9._-]*[A-Z0-9])\Z .. _dependency-specifiers-extras: From f86255b40639f1ed962496a465d67c16d443ce7d Mon Sep 17 00:00:00 2001 From: Dustin Ingram Date: Thu, 21 Aug 2025 18:33:17 +0000 Subject: [PATCH 3/3] Add history blurbs --- source/specifications/dependency-specifiers.rst | 3 +++ source/specifications/name-normalization.rst | 3 +++ 2 files changed, 6 insertions(+) diff --git a/source/specifications/dependency-specifiers.rst b/source/specifications/dependency-specifiers.rst index e1b69ff61..d9466c26e 100644 --- a/source/specifications/dependency-specifiers.rst +++ b/source/specifications/dependency-specifiers.rst @@ -526,6 +526,9 @@ History in use since late 2022. - April 2025: Added ``extras`` and ``dependency_groups`` for :ref:`lock-file-spec` as approved through :pep:`751`. +- August 2025: The suggested name validation regex was fixed to match the field + specification (it previously finished with ``$`` instead of ``\Z``, + incorrectly permitting trailing newlines) References diff --git a/source/specifications/name-normalization.rst b/source/specifications/name-normalization.rst index e295a3d11..560d956b5 100644 --- a/source/specifications/name-normalization.rst +++ b/source/specifications/name-normalization.rst @@ -53,3 +53,6 @@ History :pep:`503 <503#normalized-names>`. - November 2015: The specification of valid names was approved through :pep:`508 <508#names>`. +- August 2025: The suggested name validation regex was fixed to match the field + specification (it previously finished with ``$`` instead of ``\Z``, + incorrectly permitting trailing newlines)