Skip to content

Comments

fix: check IndexByte return before adding in tagLength#351

Merged
kjk merged 1 commit intogomarkdown:masterfrom
vnykmshr:fix-taglength-content-loss
Feb 17, 2026
Merged

fix: check IndexByte return before adding in tagLength#351
kjk merged 1 commit intogomarkdown:masterfrom
vnykmshr:fix-taglength-content-loss

Conversation

@vnykmshr
Copy link
Contributor

Fixes #350.

tagLength() adds the bytes.IndexByte return value directly to i. When > is not found, the -1 return decrements i instead of making it negative, so the if i < 0 guard never triggers. This causes leftAngle() to silently skip characters.

What changed

  • parser/inline.go: store IndexByte result in j, check for -1 before adding to i
  • inline_test.go: added TestTagLengthUnclosedAngle verifying that unclosed angle brackets with short tag names preserve content

tagLength() adds the return value of bytes.IndexByte directly to the
current index. When '>' is not found, IndexByte returns -1, which
decrements i instead of making it negative. The guard `if i < 0`
never triggers, causing leftAngle() to silently skip characters.

Store the IndexByte result in a separate variable and check it before
adding to i.
@kjk kjk merged commit a0dc97a into gomarkdown:master Feb 17, 2026
1 check passed
@kjk
Copy link
Contributor

kjk commented Feb 17, 2026

thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

tagLength silently drops content when closing > is missing

2 participants