all repos — grayfriday @ 0c62e28e900533ff5d0376fac2e5b0c4894e1fa3

blackfriday fork with a few changes

add an infinity-loop detection to block-level parsing
Mathias Leppich mleppich@muhqu.de
Sun, 30 Mar 2014 00:04:45 +0100
commit

0c62e28e900533ff5d0376fac2e5b0c4894e1fa3

parent

d4c367a949cd944e160b5fe17fcbdd347523a16c

1 files changed, 15 insertions(+), 0 deletions(-)

jump to
M block.goblock.go

@@ -31,8 +31,23 @@ return

} p.nesting++ + lastLen := 0 + sameLenCount := 0 + // parse out one block-level construct at a time for len(data) > 0 { + curLen := len(data) + if curLen == lastLen { + sameLenCount += 1 + if sameLenCount >= 3 { + // infinity loop detection + return + } + } else { + sameLenCount = 0 + } + lastLen = curLen + // prefixed header: // // # Header 1