summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2009-09-30 05:52:03 +0000
committerZac Medico <zmedico@gentoo.org>2009-09-30 05:52:03 +0000
commita02f455a6b8ed2772a63e39deed5b84378d9b555 (patch)
tree556e136cea685a28cd82de98030abd28fe4f1113
parentd76e387caab6b75fc6b2b9fb894c5d9440f2a056 (diff)
downloadportage-a02f455a6b8ed2772a63e39deed5b84378d9b555.tar.gz
portage-a02f455a6b8ed2772a63e39deed5b84378d9b555.tar.bz2
portage-a02f455a6b8ed2772a63e39deed5b84378d9b555.zip
Use a regular expression for SLOT validation inside vardbapi.aux_get().
svn path=/main/trunk/; revision=14467
-rw-r--r--pym/portage/dbapi/vartree.py10
-rw-r--r--pym/portage/dep.py5
2 files changed, 9 insertions, 6 deletions
diff --git a/pym/portage/dbapi/vartree.py b/pym/portage/dbapi/vartree.py
index 9d1755e9f..93fbfe397 100644
--- a/pym/portage/dbapi/vartree.py
+++ b/pym/portage/dbapi/vartree.py
@@ -12,7 +12,7 @@ import portage
portage.proxy.lazyimport.lazyimport(globals(),
'portage.checksum:_perform_md5_merge@perform_md5',
'portage.dep:dep_getkey,isjustname,match_from_list,' + \
- 'use_reduce,paren_reduce',
+ 'use_reduce,paren_reduce,_slot_re',
'portage.elog:elog_process',
'portage.elog.filtering:filter_mergephases,filter_unmergephases',
'portage.locks:lockdir,unlockdir',
@@ -1251,10 +1251,12 @@ class vardbapi(dbapi):
cache_data[aux_key] = mydata[aux_key]
self._aux_cache["packages"][mycpv] = (mydir_mtime, cache_data)
self._aux_cache["modified"].add(mycpv)
- if not mydata['SLOT']:
- # Empty slot triggers InvalidAtom exceptions when generating slot
- # atoms for packages, so translate it to '0' here.
+
+ if _slot_re.match(mydata['SLOT']) is None:
+ # Empty or invalid slot triggers InvalidAtom exceptions when
+ # generating slot atoms for packages, so translate it to '0' here.
mydata['SLOT'] = _unicode_decode('0')
+
return [mydata[x] for x in wants]
def _aux_get(self, mycpv, wants, st=None):
diff --git a/pym/portage/dep.py b/pym/portage/dep.py
index 8a2e781b4..70d95e484 100644
--- a/pym/portage/dep.py
+++ b/pym/portage/dep.py
@@ -808,7 +808,8 @@ def dep_getusedeps( depend ):
# 2.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+.-]*)'
+_slot = r'([\w+][\w+.-]*)'
+_slot_re = re.compile('^' + _slot + '$', re.VERBOSE)
_use = r'\[.*\]'
_op = r'([=~]|[><]=?)'
@@ -816,7 +817,7 @@ _op = r'([=~]|[><]=?)'
_atom_re = re.compile('^(?P<without_use>(?:' +
'(?P<op>' + _op + _cpv + ')|' +
'(?P<star>=' + _cpv + r'\*)|' +
- '(?P<simple>' + _cp + '))(?:' + _slot + ')?)(' + _use + ')?$', re.VERBOSE)
+ '(?P<simple>' + _cp + '))(:' + _slot + ')?)(' + _use + ')?$', re.VERBOSE)
def isvalidatom(atom, allow_blockers=False):
"""