all repos — grayfriday @ 7b5191107ef9116a1ce524d90fe241be9edb77a3

blackfriday fork with a few changes

Merge pull request #73 from johnsto/bugfix/fenced-code-append

Fix fenced code extension modifying data beyond slice
Vytautas Ĺ altenis vytas@rtfb.lt
Sat, 03 May 2014 15:15:44 +0300
commit

7b5191107ef9116a1ce524d90fe241be9edb77a3

parent

717a976f69634a0e5a08abcf3a6ce686a5d482a8

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:]), len(input[beg:]) + 1) + 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 }