git.iko.soy/typeable/pandoc
on master help sign in
Treat four or more `~` or `^` in an inline context as regular text.

This avoids exponential parsing blowups with long strings of these characters. Closes #507.

commitb79df946d1e162c9b6eae82674490b6425b0c9f2 authorJohn MacFarlane <jgm@berkeley.edu> dateTue 8 May 2012, 13:31 (14 years ago) parentffef28e
1 file changed+3−3
src/Text/Pandoc/Readers/Markdown.hs+3−3
src/Text/Pandoc/Readers/Markdown.hs+3−3
@@ -1026,11 +1026,11 @@ mathInline = try $ do
10261026 notFollowedBy digit
10271027 return $ intercalate " " words'
10281028
1029−-- to avoid performance problems, treat 4 or more _ or * in a row as a literal
1030−-- rather than attempting to parse for emph/strong
1029+-- to avoid performance problems, treat 4 or more _ or * or ~ or ^ in a row
1030+-- as a literal rather than attempting to parse for emph/strong/strikeout/super/sub
10311031fours :: GenParser Char st Inline
10321032fours = try $ do
1033− x <- char '*' <|> char '_'
1033+ x <- char '*' <|> char '_' <|> char '~' <|> char '^'
10341034 count 2 $ satisfy (==x)
10351035 rest <- many1 (satisfy (==x))
10361036 return $ Str (x:x:x:rest)