From 875f8f36545d1c21fa3d29c52c40517a667f2574 Mon Sep 17 00:00:00 2001 From: Albert Krewinkel Date: Fri, 14 May 2021 11:58:58 +0200 Subject: HTML reader: don't fail on unmatched closing "script" tag. Prevent the reader from crashing if the HTML input contains an unmatched closing `` tag. Fixes: #7282 --- src/Text/Pandoc/Readers/HTML.hs | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'src/Text/Pandoc') diff --git a/src/Text/Pandoc/Readers/HTML.hs b/src/Text/Pandoc/Readers/HTML.hs index f5c8a2277..0a9d67e35 100644 --- a/src/Text/Pandoc/Readers/HTML.hs +++ b/src/Text/Pandoc/Readers/HTML.hs @@ -942,13 +942,15 @@ getTagName (TagClose t) = Just t getTagName _ = Nothing isInlineTag :: Tag Text -> Bool -isInlineTag t = - isCommentTag t || - case getTagName t of - Nothing -> False - Just "script" -> "math/tex" `T.isPrefixOf` fromAttrib "type" t - Just x -> x `Set.notMember` blockTags || - T.take 1 x == "?" -- processing instr. +isInlineTag t = isCommentTag t || case t of + TagOpen "script" _ -> "math/tex" `T.isPrefixOf` fromAttrib "type" t + TagClose "script" -> True + TagOpen name _ -> isInlineTagName name + TagClose name -> isInlineTagName name + _ -> False + where isInlineTagName x = + x `Set.notMember` blockTags || + T.take 1 x == "?" -- processing instr. isBlockTag :: Tag Text -> Bool isBlockTag t = isBlockTagName || isTagComment t -- cgit v1.2.3