summaryrefslogtreecommitdiffstats
path: root/pym/portage_dep.py
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2007-06-11 02:49:15 +0000
committerZac Medico <zmedico@gentoo.org>2007-06-11 02:49:15 +0000
commitc69b0f404b40e56e05c9ab443353cb7332c61183 (patch)
tree93f8494b3265a635ce7f660790e3b9bfc80bcb75 /pym/portage_dep.py
parentd0dc4df791e8500e89c955a09436f5f2a0385d7e (diff)
downloadportage-c69b0f404b40e56e05c9ab443353cb7332c61183.tar.gz
portage-c69b0f404b40e56e05c9ab443353cb7332c61183.tar.bz2
portage-c69b0f404b40e56e05c9ab443353cb7332c61183.zip
For bug #181355, detect parenthesis mismatch in paren_reduce(), raise an InvalidDependString exception, and make sure that all callers handle the exception properly. (trunk r6795:6797)
svn path=/main/branches/2.1.2/; revision=6798
Diffstat (limited to 'pym/portage_dep.py')
-rw-r--r--pym/portage_dep.py11
1 files changed, 9 insertions, 2 deletions
diff --git a/pym/portage_dep.py b/pym/portage_dep.py
index b87058f7f..a8007857e 100644
--- a/pym/portage_dep.py
+++ b/pym/portage_dep.py
@@ -69,13 +69,20 @@ def paren_reduce(mystr,tokenize=1):
"""
mylist = []
while mystr:
- if ("(" not in mystr) and (")" not in mystr):
+ left_paren = mystr.find("(")
+ has_left_paren = left_paren != -1
+ right_paren = mystr.find(")")
+ has_right_paren = right_paren != -1
+ if not has_left_paren and not has_right_paren:
freesec = mystr
subsec = None
tail = ""
elif mystr[0] == ")":
return [mylist,mystr[1:]]
- elif ("(" in mystr) and (mystr.index("(") < mystr.index(")")):
+ elif has_left_paren and not has_right_paren:
+ raise portage_exception.InvalidDependString(
+ "missing right parenthesis: '%s'" % mystr)
+ elif has_left_paren and left_paren < right_paren:
freesec,subsec = mystr.split("(",1)
subsec,tail = paren_reduce(subsec,tokenize)
else: