commit: bf135e4746a4b4f21132832c0c2bcb966948e25c Author: Jannik Glückert <jannik.glueckert <AT> gmail <DOT> com> AuthorDate: Sat Jun 14 11:02:57 2025 +0000 Commit: Sam James <sam <AT> gentoo <DOT> org> CommitDate: Mon Oct 20 17:31:51 2025 +0000 URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=bf135e47
versions: respect "must not begin with a plus" categories, packages and slots must not begin with a plus. This has been the case since at least EAPI 5, it's about time to enforce it. Signed-off-by: Jannik Glückert <jannik.glueckert <AT> gmail.com> Part-of: https://github.com/gentoo/portage/pull/1445 Signed-off-by: Sam James <sam <AT> gentoo.org> lib/portage/tests/dep/test_atom.py | 8 ++++++++ lib/portage/versions.py | 12 ++++++------ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/lib/portage/tests/dep/test_atom.py b/lib/portage/tests/dep/test_atom.py index b7d8bee8b4..9cdc14cf56 100644 --- a/lib/portage/tests/dep/test_atom.py +++ b/lib/portage/tests/dep/test_atom.py @@ -152,6 +152,14 @@ class TestAtom(TestCase): tests_xfail = ( (Atom("sys-apps/portage"), False, False), + ("+cat/pkg", False, False), + ("-cat/pkg", False, False), + (".cat/pkg", False, False), + ("cat/+pkg", False, False), + ("cat/-pkg", False, False), + ("cat/pkg:+slot", False, False), + ("cat/pkg:-slot", False, False), + ("cat/pkg:.slot", False, False), ("cat/pkg[a!]", False, False), ("cat/pkg[!a]", False, False), ("cat/pkg[!a!]", False, False), diff --git a/lib/portage/versions.py b/lib/portage/versions.py index c7eb91b384..e7c09fc978 100644 --- a/lib/portage/versions.py +++ b/lib/portage/versions.py @@ -40,17 +40,17 @@ _unknown_repo = "__unknown__" # \w is [a-zA-Z0-9_] # PMS 3.1.3: A slot name may contain any of the characters [A-Za-z0-9+_.-]. -# It must not begin with a hyphen or a dot. -_slot = r"([\w+][\w+.-]*)" +# It must not begin with a hyphen, a dot or a plus sign. +_slot = r"([\w][\w+.-]*)" # 2.1.1 A category name may contain any of the characters [A-Za-z0-9+_.-]. -# It must not begin with a hyphen or a dot. -_cat = r"[\w+][\w+.-]*" +# It must not begin with a hyphen, a dot or a plus sign. +_cat = r"[\w][\w+.-]*" # 2.1.2 A package name may contain any of the characters [A-Za-z0-9+_-]. -# It must not begin with a hyphen, +# It must not begin with a hyphen or a plus sign, # and must not end in a hyphen followed by one or more digits. -_pkg = r"[\w+][\w+-]*?" +_pkg = r"[\w][\w+-]*?" _v = r"(\d+)((\.\d+)*)([a-z]?)((_(pre|p|beta|alpha|rc)\d*)*)" _rev = r"\d+"
