Skip to content

Commit

Permalink
config: fix unquoting list of options
Browse files Browse the repository at this point in the history
  • Loading branch information
Radek Novacek committed Jul 26, 2016
1 parent 418474a commit 4054161
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions virtwho/config.py
Expand Up @@ -346,7 +346,9 @@ def get(self, section, option):
# Don't call super, SafeConfigParser is not inherited from object
value = SafeConfigParser.get(self, section, option)
for quote in ('"', "'"):
if value.startswith(quote) and value.endswith(quote):
# Strip the quotes only when the value starts with quote,
# ends with quote but doesn't contain it inside
if value.startswith(quote) and value.endswith(quote) and quote not in value[1:-1]:
return value.strip(quote)
return value

Expand Down Expand Up @@ -393,7 +395,7 @@ def _readConfig(self, parser):
self.logger.error(str(e))

def readFile(self, filename):
parser = SafeConfigParser()
parser = StripQuotesConfigParser()
fname = parser.read(filename)
if len(fname) == 0:
self.logger.error("Unable to read configuration file %s", filename)
Expand Down Expand Up @@ -427,7 +429,7 @@ def getSections(parser):
def parseFile(filename, logger=None):
# Parse a file into a dict of section_name: options_dict
# options_dict is a dict of option_name: value
parser = SafeConfigParser()
parser = StripQuotesConfigParser()
fname = parser.read(filename)
if len(fname) == 0 and logger:
logger.error("Unable to read configuration file %s", filename)
Expand Down

0 comments on commit 4054161

Please sign in to comment.