From 80a4a03df7cae09c73453322729653f9bffbdd75 Mon Sep 17 00:00:00 2001 From: fiddlosopher Date: Sun, 29 Nov 2009 19:31:58 +0000 Subject: Markdown reader: treat 4 or more * or _ in a row as literal text. (Instead of trying to parse as strong or emph, which leads to exponential performance problems.) git-svn-id: https://pandoc.googlecode.com/svn/trunk@1634 788f1e2b-df1e-0410-8736-df70ead52e1b --- src/Text/Pandoc/Readers/Markdown.hs | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/Text') diff --git a/src/Text/Pandoc/Readers/Markdown.hs b/src/Text/Pandoc/Readers/Markdown.hs index adc41238c..f4384d493 100644 --- a/src/Text/Pandoc/Readers/Markdown.hs +++ b/src/Text/Pandoc/Readers/Markdown.hs @@ -824,6 +824,7 @@ inlineParsers = [ str , endline , code , charRef + , (fourOrMore '*' <|> fourOrMore '_') , strong , emph , note @@ -921,6 +922,12 @@ mathInline = try $ do notFollowedBy digit return $ intercalate " " words' +-- to avoid performance problems, treat 4 or more _ or * in a row as a literal +-- rather than attempting to parse for emph/strong +fourOrMore :: Char -> GenParser Char st Inline +fourOrMore c = try $ count 4 (char c) >> many (char c) >>= \s -> + return (Str $ replicate 4 c ++ s) + emph :: GenParser Char ParserState Inline emph = ((enclosed (char '*') (notFollowedBy' strong >> char '*') inline) <|> (enclosed (char '_') (notFollowedBy' strong >> char '_' >> -- cgit v1.2.3