From: Arfrever Frehtes Taifersar Arahesis Date: Thu, 9 Jun 2011 14:23:28 +0000 (-0700) Subject: use_reduce: disallow empty parens X-Git-Tag: v2.2.0_alpha39~10 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=1faa9bddc2859c73ce8984b43eca816c30bdb5f1;p=portage.git use_reduce: disallow empty parens This will fix bug #370565. --- diff --git a/pym/portage/dep/__init__.py b/pym/portage/dep/__init__.py index 862154318..ba373241f 100644 --- a/pym/portage/dep/__init__.py +++ b/pym/portage/dep/__init__.py @@ -369,6 +369,9 @@ def use_reduce(depstr, uselist=[], masklist=[], matchall=False, excludeall=[], i if need_simple_token: raise InvalidDependString( _("expected: file name, got: '%s', token %s") % (token, pos+1)) + if len(mysplit) >= pos+2 and mysplit[pos+1] == ")": + raise InvalidDependString( + _("expected: dependency string, got: ')', token %s") % (pos+1,)) need_bracket = False stack.append([]) level += 1 diff --git a/pym/portage/tests/dep/test_use_reduce.py b/pym/portage/tests/dep/test_use_reduce.py index 7c7286ad8..b89752fb4 100644 --- a/pym/portage/tests/dep/test_use_reduce.py +++ b/pym/portage/tests/dep/test_use_reduce.py @@ -217,7 +217,7 @@ class UseReduce(TestCase): uselist = ["foo", "bar"], expected_result = [ "||", [ "A", "B" ] ]), UseReduceTestCase( - "A || ( ) foo? ( ) B", + "A || ( bar? ( C ) ) foo? ( bar? ( C ) ) B", expected_result = ["A", "B"]), UseReduceTestCase( "|| ( A ) || ( B )", @@ -350,7 +350,7 @@ class UseReduce(TestCase): opconvert = True, expected_result = [['||', 'A', 'B']]), UseReduceTestCase( - "A || ( ) foo? ( ) B", + "A || ( bar? ( C ) ) foo? ( bar? ( C ) ) B", opconvert = True, expected_result = ["A", "B"]), UseReduceTestCase( @@ -509,7 +509,7 @@ class UseReduce(TestCase): flat = True, expected_result = [ "||", "||", "A", "||", "B" ]), UseReduceTestCase( - "A || ( ) foo? ( ) B", + "A || ( bar? ( C ) ) foo? ( bar? ( C ) ) B", flat = True, expected_result = ["A", "||", "B"]), UseReduceTestCase(