Repository navigation
Fix parsing and writing bugs reported against v1 - #435
Merged
Merged
Conversation
- Keep comment symbols inside a quoted value (issue 393, issue 328). - Keep comment lines after the last key and write them back (issue 362). - Skip a repeated byte order mark (issue 390). - With SpaceBeforeInlineComment, start the comment at the first " #" or " ;" (issue 426). - With AllowPythonMultilineValues, keep empty lines followed by an indented line (issue 205). - Treat a raw section with an empty body as raw (issue 291). - Don't wrap a value in """ for a backtick in the middle (issue 352). - Add AllowBracketedValues to read a JSON-like value across lines (issue 344).
A value such as JSON can span lines in triple quotes, so the option isn't needed. Its scan made parsing quadratic and skipped Python multiline continuation.
A default section with keys followed by an empty [DEFAULT] header under RawSections became raw, and Write then refused it. Also correct the migration notes on write output, repeated byte order marks, Python multiline values and where trailing comments are written.
This was referenced Nov 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Describe the pull request
Fixes seven bugs reported against v1 that v2 still had.
Default parsing changes:
#and;inside its quotes, sok = "a#b"isa#b. v1 read"a. Text other than a comment after the closing quote still cuts the value as before. value parsed incorrectly when a comment symbol (#) is inside a quoted string #393, If the configuration item of my ini configuration file contains #, it will cause an error in reading the configuration. #328.With options:
SpaceBeforeInlineComment: the first#or;starts the comment. v1 always looked for#first. SpaceBeforeInlineComment cuts at " #" even when " ;" comes first #426.AllowPythonMultilineValues: empty lines followed by an indented line stay in the value, as in Python's configparser. Fails to parse multiline fields with blank lines #205.RawSections: a raw section with an empty body is raw, soSetBodyworks on it. A section that already has keys, such as the default one, stays a key section. Empty UnparseableSections is not marked as rawBody #291.Writing: a value with a backtick in the middle is no longer wrapped in
""", unless it also has a comment symbol. #352.#344 (multi-line JSON values) isn't fixed here: such a value can already be written in
"""quotes.The migration guide, README and package docs no longer say v2 parses every input exactly as v1, and list these fixes.
Link to the issue: #393, #328, #362, #390, #426, #205, #291, #352
Checklist
Tests: lexer tests for each parsing fix, write round-trip cases for the footer, backtick quoting and an empty raw header after keys, new fuzz inputs, and a fuzz regression seed.
go test -race ./..., lint and 1 minute ofFuzzWriteRoundTrippass.AI usage
Written with Amp.