From 6d8eb95850d7f945cec92e79a99cf782f73071b3 Mon Sep 17 00:00:00 2001 From: kyleknap Date: Wed, 25 Feb 2015 12:18:16 -0800 Subject: [PATCH 1/3] Fix issue with parsing Issue was if there is a ] inside one of the values of a list. The end character would get removed. So something like ``foo=[bar, *[biz]*, bar]`` would get parsed to ``foo=bar,*[biz],bar``. --- awscli/utils.py | 2 +- tests/unit/test_utils.py | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/awscli/utils.py b/awscli/utils.py index 84c17d69610f..796100ded2cb 100644 --- a/awscli/utils.py +++ b/awscli/utils.py @@ -85,7 +85,7 @@ def _eat_items(value, iter_parts, part, end_char, replace_char=''): except StopIteration: raise ValueError(value) chunks.append(current.replace(replace_char, '')) - if end_char in current: + if end_char == current[-1]: break return ','.join(chunks) diff --git a/tests/unit/test_utils.py b/tests/unit/test_utils.py index 16d3eeb20484..20eabebeddb7 100644 --- a/tests/unit/test_utils.py +++ b/tests/unit/test_utils.py @@ -82,3 +82,7 @@ def test_missing_bracket2(self): def test_bracket_in_middle(self): self.assertEqual(split_on_commas('foo,bar=a[b][c],baz'), ['foo', 'bar=a[b][c]', 'baz']) + + def test_end_bracket_in_value(self): + self.assertEqual(split_on_commas('foo,bar=[foo,*[biz]*,baz]'), + ['foo', 'bar=foo,*[biz]*,baz']) From 295fbd1f2f6e72f065b0a7605c44b81c6b2cf3e0 Mon Sep 17 00:00:00 2001 From: kyleknap Date: Wed, 25 Feb 2015 14:54:29 -0800 Subject: [PATCH 2/3] Update changelog --- CHANGELOG.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 048c3878cdb8..39682429e5f2 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -8,6 +8,10 @@ Next Release (TBD) * feature:``aws cloudtrail``: Add support for regionalized policy templates for the ``create-subscription`` and ``update-subscription`` commands. (`issue 1167 `__) +* bugfix:parsing: Fix issue where if there is a square bracket inside one + of the values of a list, the end character would get removed. + (`issue 1183 `__) + 1.7.12 ====== From 248d917ab553666910a7d56eb9f780e6c4c93024 Mon Sep 17 00:00:00 2001 From: kyleknap Date: Wed, 25 Feb 2015 15:03:53 -0800 Subject: [PATCH 3/3] Switched check to use endswith instead of indexes --- awscli/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/awscli/utils.py b/awscli/utils.py index 796100ded2cb..9c86db041309 100644 --- a/awscli/utils.py +++ b/awscli/utils.py @@ -85,7 +85,7 @@ def _eat_items(value, iter_parts, part, end_char, replace_char=''): except StopIteration: raise ValueError(value) chunks.append(current.replace(replace_char, '')) - if end_char == current[-1]: + if current.endswith(end_char): break return ','.join(chunks)