From: Zac Medico Date: Wed, 30 Sep 2009 05:52:03 +0000 (-0000) Subject: Use a regular expression for SLOT validation inside vardbapi.aux_get(). X-Git-Tag: v2.2_rc43~12 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=a02f455a6b8ed2772a63e39deed5b84378d9b555;p=portage.git Use a regular expression for SLOT validation inside vardbapi.aux_get(). svn path=/main/trunk/; revision=14467 --- 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(?:' + '(?P' + _op + _cpv + ')|' + '(?P=' + _cpv + r'\*)|' + - '(?P' + _cp + '))(?:' + _slot + ')?)(' + _use + ')?$', re.VERBOSE) + '(?P' + _cp + '))(:' + _slot + ')?)(' + _use + ')?$', re.VERBOSE) def isvalidatom(atom, allow_blockers=False): """