Merged revisions 71537 via svnmerge from

svn+ssh://pythondev@svn.python.org/python/trunk

........
  r71537 | georg.brandl | 2009-04-12 19:24:11 +0200 (So, 12 Apr 2009) | 1 line

  #5741: dont disallow double percent signs in SafeConfigParser.set() keys.
........
This commit is contained in:
Georg Brandl 2009-04-27 16:42:58 +00:00
parent f3532df236
commit 1f9fa31cb5
3 changed files with 11 additions and 4 deletions

View file

@ -620,7 +620,6 @@ class SafeConfigParser(ConfigParser):
return ''.join(L)
_interpvar_re = re.compile(r"%\(([^)]+)\)s")
_badpercent_re = re.compile(r"%[^%]|%$")
def _interpolate_some(self, option, accum, rest, section, map, depth):
if depth > MAX_INTERPOLATION_DEPTH:
@ -667,9 +666,10 @@ class SafeConfigParser(ConfigParser):
# check for bad percent signs:
# first, replace all "good" interpolations
tmp_value = self._interpvar_re.sub('', value)
tmp_value = tmp_value.replace('%%', '')
# then, check if there's a lone percent sign left
m = self._badpercent_re.search(tmp_value)
if m:
percent_index = tmp_value.find('%')
if percent_index != -1:
raise ValueError("invalid interpolation syntax in %r at "
"position %d" % (value, m.start()))
"position %d" % (value, percent_index))
ConfigParser.set(self, section, option, value)