git.iko.soy/typeable/pandoc
on master help sign in
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

commit875f8f36545d1c21fa3d29c52c40517a667f2574 authorAlbert Krewinkel <albert@zeitkraut.de> dateFri 14 May 2021, 11:58 (5 years ago) parent3f09f53
2 files changed+16−7
src/Text/Pandoc/Readers/HTML.hs+9−7 test/command/7282.md+7
src/Text/Pandoc/Readers/HTML.hs+9−7
@@ -942,13 +942,15 @@ getTagName (TagClose t) = Just t
942942getTagName _ = Nothing
943943
944944isInlineTag :: Tag Text -> Bool
945−isInlineTag t =
946− isCommentTag t ||
947− case getTagName t of
948− Nothing -> False
949− Just "script" -> "math/tex" `T.isPrefixOf` fromAttrib "type" t
950− Just x -> x `Set.notMember` blockTags ||
951− T.take 1 x == "?" -- processing instr.
945+isInlineTag t = isCommentTag t || case t of
946+ TagOpen "script" _ -> "math/tex" `T.isPrefixOf` fromAttrib "type" t
947+ TagClose "script" -> True
948+ TagOpen name _ -> isInlineTagName name
949+ TagClose name -> isInlineTagName name
950+ _ -> False
951+ where isInlineTagName x =
952+ x `Set.notMember` blockTags ||
953+ T.take 1 x == "?" -- processing instr.
952954
953955isBlockTag :: Tag Text -> Bool
954956isBlockTag t = isBlockTagName || isTagComment t
test/command/7282.mdnew file+7
@@ -0,0 +1,7 @@
1+Don't crash on unmatched closing tag.
2+```
3+% pandoc -f html -t native
4+</script>
5+^D
6+[]
7+```