Issue 23301: ConfigParser does not handle square brackets in section name (original) (raw)

Issue23301

Created on 2015-01-22 15:58 by xflr6, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Messages (2)
msg234497 - (view) Author: Sebastian Bank (xflr6) Date: 2015-01-22 15:58
ConfigParser parses section lines containing square brackets like '[spam [eggs] spam]' up to the first instead of the last occurrence of ']' preventing roundtrips: >>> s = StringIO() >>> c1 = ConfigParser() >>> c1.add_section('spam [eggs]') >>> c1.write(s) >>> s.seek(0) >>> c2 = ConfigParser() >>> c2.readfp(s) >>> assert c1.sections() == c2.sections() # fails Potential fix: change the second line of SECTCRE from r'(?P
[^]]+)' to r'(?P
.+?)'. If the parsing behaviour cannot be changed, the user should at least be warned about supplying data that breaks the roundtrip.
msg234498 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2015-01-22 16:06
This is a duplicate of issue 20923, which was rejected. To argue against the rejection you probably need to provide evidence that this is something that is actually supported by other common ini parsers. And that evidence should be posted to issue 20923.
History
Date User Action Args
2022-04-11 14:58:12 admin set github: 67490
2015-01-22 16:06:52 r.david.murray set status: open -> closedsuperseder: [doc] Explain ConfigParser 'valid section name' and .SECTCREnosy: + r.david.murraymessages: + resolution: duplicatestage: resolved
2015-01-22 15:58:05 xflr6 create