aboutsummaryrefslogtreecommitdiff
path: root/src/Text
diff options
context:
space:
mode:
authorAlbert Krewinkel <albert@zeitkraut.de>2021-05-14 11:58:58 +0200
committerAlbert Krewinkel <albert@zeitkraut.de>2021-05-14 12:13:40 +0200
commit875f8f36545d1c21fa3d29c52c40517a667f2574 (patch)
treef20c0f9f7277da55e5ed459fd777d4e86ff9c08c /src/Text
parent3f09f53459b877f53072efbf57dec21fa37280b5 (diff)
downloadpandoc-875f8f36545d1c21fa3d29c52c40517a667f2574.tar.gz
HTML reader: don't fail on unmatched closing "script" tag.
Prevent the reader from crashing if the HTML input contains an unmatched closing `</script>` tag. Fixes: #7282
Diffstat (limited to 'src/Text')
-rw-r--r--src/Text/Pandoc/Readers/HTML.hs16
1 files changed, 9 insertions, 7 deletions
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