You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
ConfigParser accepts delimiters in key name which corrupts .ini file #128843
Delimiters are substrings that delimit keys from values within a section. The first occurrence of a delimiting substring on a line is considered a delimiter. This means values (BUT NOT KEYS) can contain substrings that are in the delimiters".
(emphasis mine)
But as of today's 3.13, nothing stops the user from using delimiters in keys, writing them to a file and finally reading back something completely different. Reproduction:
importconfigparsercfg2file=configparser.ConfigParser()
cfg2file['section1'] = {}
# This should fail. It "succeeds".cfg2file['section1']['one=two'] ='three'# Write ambiguous 'one = two = three' line in the .ini filewithopen('example.ini', 'w') asconfigfile:
cfg2file.write(configfile)
# Read the file back. First equal sign wins.file2cfg=configparser.ConfigParser()
file2cfg.read('example.ini')
forkeyinfile2cfg['section1']:
print(key+' is: '+file2cfg['section1'][key] )
# Trueassertcfg2file['section1']['one=two'] =='three'# False!assertfile2cfg['section1']['one=two'] =='three'# This is True insteadassertfile2cfg['section1']['one'] =='two = three'
This happens when someone enters west config key=val ... instead of west config key val ...:
Issue #65697 is about keys that look like comments, but also mentions keys with an equals sign
Issue #69909 is also similar, but focusses on add_section
Activity
vadmium commentedon Jan 15, 2025
Issue #65697 is about keys that look like comments, but also mentions keys with an equals sign
Issue #69909 is also similar, but focusses on add_section
jaraco commentedon Jan 15, 2025
I'm going to close this as a duplicate of #65697.