summaryrefslogtreecommitdiffstats
path: root/pym/portage/dep.py
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2007-06-11 02:05:43 +0000
committerZac Medico <zmedico@gentoo.org>2007-06-11 02:05:43 +0000
commitce33c5cc4d61157234da1b612379fc098c1d3ae3 (patch)
treefa2cd1c5259449cca4f4caba816e923d8423caa2 /pym/portage/dep.py
parentc1f8e69d58a5e5a843f42f2750f69505274260cc (diff)
downloadportage-ce33c5cc4d61157234da1b612379fc098c1d3ae3.tar.gz
portage-ce33c5cc4d61157234da1b612379fc098c1d3ae3.tar.bz2
portage-ce33c5cc4d61157234da1b612379fc098c1d3ae3.zip
For bug #181355, detect parenthesis mismatch in paren_reduce(), raise an InvalidDependString exception, and make sure that all callers handle the exception properly.
svn path=/main/trunk/; revision=6796
Diffstat (limited to 'pym/portage/dep.py')
-rw-r--r--pym/portage/dep.py14
1 files changed, 12 insertions, 2 deletions
diff --git a/pym/portage/dep.py b/pym/portage/dep.py
index 9474c1f25..86975ae26 100644
--- a/pym/portage/dep.py
+++ b/pym/portage/dep.py
@@ -89,13 +89,23 @@ 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_right_paren and not has_left_paren:
+ raise portage.exception.InvalidDependString(
+ "missing left parenthesis: '%s'" % mystr)
+ elif has_left_paren and left_paren < right_paren:
freesec,subsec = mystr.split("(",1)
subsec,tail = paren_reduce(subsec,tokenize)
else: