diff options
| -rw-r--r-- | openstack/common/iniparser.py | 5 | ||||
| -rw-r--r-- | tests/unit/test_iniparser.py | 9 |
2 files changed, 13 insertions, 1 deletions
diff --git a/openstack/common/iniparser.py b/openstack/common/iniparser.py index 53ca023..e91eea5 100644 --- a/openstack/common/iniparser.py +++ b/openstack/common/iniparser.py @@ -52,7 +52,10 @@ class BaseParser(object): else: key, value = line[:colon], line[colon + 1:] - return key.strip(), [value.strip()] + value = value.strip() + if value[0] == value[-1] and value[0] == "\"" or value[0] == "'": + value = value[1:-1] + return key.strip(), [value] def parse(self, lineiter): key = None diff --git a/tests/unit/test_iniparser.py b/tests/unit/test_iniparser.py index 5b3a0de..5d6e79f 100644 --- a/tests/unit/test_iniparser.py +++ b/tests/unit/test_iniparser.py @@ -104,6 +104,15 @@ class ParserTestCase(unittest.TestCase): self.parser.parse(lines) self.assertTrue(self.parser.comment_called) + def test_assignment_space_single_quote(self): + lines = ["foo = ' bar '"] + self.parser.parse(lines) + self.assertEquals(self.parser.values, {'': {'foo': [' bar ']}}) + + def test_assignment_space_double_quote(self): + lines = ["foo = \" bar \""] + self.parser.parse(lines) + self.assertEquals(self.parser.values, {'': {'foo': [' bar ']}}) class ExceptionTestCase(unittest.TestCase): def test_parseerror(self): |
