summaryrefslogtreecommitdiffstats
path: root/Lib/ConfigParser.py
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2009-04-12 17:24:11 (GMT)
committerGeorg Brandl <georg@python.org>2009-04-12 17:24:11 (GMT)
commit21cf5ee6fdb190393d27b03f6b3c5453d97859df (patch)
tree2a6e224bb253d75c3e60e6e3da69325fc8947acf /Lib/ConfigParser.py
parent3295eed64b8d43d9dc090c169942192c8d1b781b (diff)
downloadcpython-21cf5ee6fdb190393d27b03f6b3c5453d97859df.zip
cpython-21cf5ee6fdb190393d27b03f6b3c5453d97859df.tar.gz
cpython-21cf5ee6fdb190393d27b03f6b3c5453d97859df.tar.bz2
#5741: dont disallow double percent signs in SafeConfigParser.set() keys.
Diffstat (limited to 'Lib/ConfigParser.py')
-rw-r--r--Lib/ConfigParser.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/Lib/ConfigParser.py b/Lib/ConfigParser.py
index 1861b5a..2fa323b 100644
--- a/Lib/ConfigParser.py
+++ b/Lib/ConfigParser.py
@@ -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)