Repository navigation
A mapping ends with the text it has, not at a supplied null - #20
Merged
Merged
Conversation
An explicit key with no value gets a null the parser supplies for it, marked at the start of the line after the key. A mapping takes its end from its last child, so one ending in such a key reached a line past its own text, and past the whole document when the key was on the last line: `? 00` reported the mapping ending on line 2 of a one-line document, and `a:\n? b` on line 3 of a two-line one. End with the last child that the document actually wrote. A value that is merely empty rather than absent sits on the key's own line and still ends the entry, so `a:` is unchanged. Found by fuzzing kin-openapi's loader, where the recorded origin has to lie inside the input. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017e285CvofYf6joqC98gTXz
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.
An explicit key with no value gets a null that the parser supplies, marked at the start of the line after the key. A mapping takes its end from its last child, so a mapping ending in such a key reached past its own text:
? 00a:\n? bThe first row is the one that matters: the end is past the end of the document, so a consumer reconstructing the block span from
__origin__gets a line that does not exist.The fix ends the mapping at the last child the document actually wrote. A value that is merely empty rather than absent sits on the key's own line, so
a:still ends at 1:3 as before, and sequences are untouched (a valueless-gets its null on the dash's own line, which is already in bounds).Found by fuzzing kin-openapi's loader, whose origins target requires every recorded position to lie inside the input. That fuzz target has been failing on
? 00on kin's master since yesterday.Tests: a case in
end_position_test.gocovering the absent-value and empty-value forms. Full suite passes.🤖 Generated with Claude Code
https://claude.ai/code/session_017e285CvofYf6joqC98gTXz