yuin / goldmark

:trophy: A markdown parser written in Go. Easy to extend, standard(CommonMark) compliant, well structured.
MIT License
3.68k stars 255 forks source link

Fix panic in table parser #462

Closed Andrew-Morozko closed 3 weeks ago

Andrew-Morozko commented 2 months ago

Code in func (b *tableParagraphTransformer) parseRow used the segment's Value to calculate some offsets as if Value always corresponds 1 to 1 to the source. Segments with padding cause incorrect behavior generally, and an out-of-bounds source access in pathological cases.

I switched the code to use padding-aware segment.TrimLeftSpace and segment.TrimRightSpace instead of raw util.TrimLeftSpaceLength and util.TrimRightSpaceLength