toml: a captured comment may end inside a multi-byte character - #63071
Open
levy wants to merge 1 commit into
Open
toml: a captured comment may end inside a multi-byte character#63071levy wants to merge 1 commit into
levy wants to merge 1 commit into
Conversation
levy
force-pushed
the
pr-toml-comment-multibyte
branch
2 times, most recently
from
September 8, 2026 08:54
1763ddc to
77b2c2e
Compare
Member
|
change looks probably good but this needs a test (minimal is ok) |
The comment capture sliced `start:(prevpos-1)`, and `prevpos` is the index of the character after the comment, so `prevpos - 1` landed inside that character when it was multi-byte and the parser threw `StringIndexError`. Pkg reported it as "Errored when reading Project.toml". Found with a Project.toml whose comment ends in an em dash. Assisted-by: Claude Code (Opus 5)
levy
force-pushed
the
pr-toml-comment-multibyte
branch
from
September 8, 2026 16:54
77b2c2e to
dcf1e79
Compare
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.
Where this comes from. I found this while shortening the start of a compiled Julia program. This change has nothing to do with that work and needs none of it.
The comment capture of the parser slices
start:(prevpos-1), andprevposis the index of the character AFTER the comment, soprevpos - 1lands inside that character when it is multi-byte. A TOML file whose comment ends in a non-ASCII character then throwsStringIndexError, whichPkgreports asErrored when reading Project.toml.previndis the fix.Found with a
Project.tomlwhose comment ends with an em dash:Pkgcould not read the project at all, on master.