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

svn path=/main/branches/2.1.2/; revision=9011

pym/portage.py

index 7dd7d22ef7a856593ff3adc90fafd2c3c499e4b2..08accebd42daf75501b71b702d5534f22db5db9a 100644 (file)
@@ -5791,7 +5791,8 @@ class portagetree:
 
 
 class dbapi:
-       _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
 
@@ -7163,6 +7164,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()