Skip to content

toml: a captured comment may end inside a multi-byte character - #63071

Open
levy wants to merge 1 commit into
JuliaLang:masterfrom
levy:pr-toml-comment-multibyte
Open

toml: a captured comment may end inside a multi-byte character#63071
levy wants to merge 1 commit into
JuliaLang:masterfrom
levy:pr-toml-comment-multibyte

Conversation

@levy

@levy levy commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

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), and prevpos is the index of the character AFTER the comment, so prevpos - 1 lands inside that character when it is multi-byte. A TOML file whose comment ends in a non-ASCII character then throws StringIndexError, which Pkg reports as Errored when reading Project.toml.

prevind is the fix.

Found with a Project.toml whose comment ends with an em dash: Pkg could not read the project at all, on master.

@levy
levy force-pushed the pr-toml-comment-multibyte branch 2 times, most recently from 1763ddc to 77b2c2e Compare September 8, 2026 08:54
@adienes adienes added strings "Strings!" bugfix This change fixes an existing bug labels Sep 8, 2026
@adienes

adienes commented Sep 8, 2026

Copy link
Copy Markdown
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
levy force-pushed the pr-toml-comment-multibyte branch from 77b2c2e to dcf1e79 Compare September 8, 2026 16:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix This change fixes an existing bug strings "Strings!"

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants