From eedeb52d39a70a253b33f7ce8e78bb05ff7f29bd Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Fri, 21 Dec 2007 01:16:27 +0000 Subject: [PATCH] Use a regex to validate package directory names in portdbapi.cp_list() and also simplify the catagory regex a bit. svn path=/main/trunk/; revision=9010 --- pym/portage/dbapi/__init__.py | 3 ++- pym/portage/dbapi/porttree.py | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/pym/portage/dbapi/__init__.py b/pym/portage/dbapi/__init__.py index a1de0695f..0e473ddd1 100644 --- a/pym/portage/dbapi/__init__.py +++ b/pym/portage/dbapi/__init__.py @@ -13,7 +13,8 @@ from portage.versions import catpkgsplit, catsplit, pkgcmp class dbapi(object): - _category_re = re.compile(r'^[+\w][-\.+\w]*$') + _category_re = re.compile(r'^\w[-.+\w]*$') + _pkg_dir_name_re = re.compile(r'^\w[-+\w]*$') def __init__(self): pass diff --git a/pym/portage/dbapi/porttree.py b/pym/portage/dbapi/porttree.py index 7df97959d..7ce65b998 100644 --- a/pym/portage/dbapi/porttree.py +++ b/pym/portage/dbapi/porttree.py @@ -493,6 +493,9 @@ class portdbapi(dbapi): self._non_category_dirs.match(x): continue for y in listdir(oroot+"/"+x, EmptyOnError=1, ignorecvs=1, dirsonly=1): + if not self._pkg_dir_name_re.match(y) or \ + y == "CVS": + continue d[x+"/"+y] = None l = d.keys() l.sort() -- 2.26.2