Use a regex to validate package directory names in portdbapi.cp_list()
authorZac Medico <zmedico@gentoo.org>
Fri, 21 Dec 2007 01:16:27 +0000 (01:16 -0000)
committerZac Medico <zmedico@gentoo.org>
Fri, 21 Dec 2007 01:16:27 +0000 (01:16 -0000)
and also simplify the catagory regex a bit.

svn path=/main/trunk/; revision=9010

pym/portage/dbapi/__init__.py
pym/portage/dbapi/porttree.py

index a1de0695fc0b2be4c4cc591b0af4de87c64333f3..0e473ddd15a9ba8b24e0ad5459ad20885301eb65 100644 (file)
@@ -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
 
index 7df97959d8fd5e0ae1d929f781fa36ba719e6dc3..7ce65b998363b4a64d64a0865a3189e1e9a4adab 100644 (file)
@@ -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()