Stop parsing "list lines" when we hit a block tag.

This fixes exponential slowdown in certain input, e.g.
a series of lists followed by `</div>`.
This commit is contained in:
John MacFarlane 2013-12-04 10:00:40 -08:00
parent eebb15ba1d
commit 5314df51f3

View file

@ -732,7 +732,8 @@ listLine = try $ do
notFollowedBy' (do indentSpaces
many (spaceChar)
listStart)
chunks <- manyTill (liftM snd (htmlTag isCommentTag) <|> count 1 anyChar) newline
chunks <- manyTill (liftM snd (htmlTag isCommentTag) <|> count 1 (satisfy (/='<'))
<|> (notFollowedBy' (htmlTag isBlockTag) >> count 1 anyChar)) newline
return $ concat chunks
-- parse raw text for one list item, excluding start marker and continuations
@ -759,6 +760,7 @@ listContinuationLine :: MarkdownParser String
listContinuationLine = try $ do
notFollowedBy blankline
notFollowedBy' listStart
notFollowedBy' $ try $ skipMany spaceChar >> htmlTag (~== TagClose "div")
optional indentSpaces
result <- anyLine
return $ result ++ "\n"