all repos — grayfriday @ 852c1967b98c2c8154b98b844867e629f0a4d792

blackfriday fork with a few changes

Fix fenced code extn modifying data beyond slice
Dave Johnston johnsto@gmail.com
Fri, 02 May 2014 23:05:06 +0100
commit

852c1967b98c2c8154b98b844867e629f0a4d792

parent

c76eb63418dc02591a80541fb40b339c0f558697

1 files changed, 4 insertions(+), 1 deletions(-)

jump to
M markdown.gomarkdown.go

@@ -331,7 +331,10 @@

if p.flags&EXTENSION_FENCED_CODE != 0 { // when last line was none blank and a fenced code block comes after if beg >= lastFencedCodeBlockEnd { - if i := p.fencedCode(&out, append(input[beg:], '\n'), false); i > 0 { + // tmp var so we don't modify beyond bounds of `input` + var tmp = make([]byte, len(input[beg:])) + copy(tmp, input[beg:]) + if i := p.fencedCode(&out, append(tmp, '\n'), false); i > 0 { if !lastLineWasBlank { out.WriteByte('\n') // need to inject additional linebreak }