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
This commit is contained in:
Albert Krewinkel 2021-05-14 11:58:58 +02:00
parent 3f09f53459
commit 875f8f3654
No known key found for this signature in database
GPG key ID: 388DC0B21F631124
2 changed files with 16 additions and 7 deletions

View file

@ -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

7
test/command/7282.md Normal file
View file

@ -0,0 +1,7 @@
Don't crash on unmatched closing tag.
```
% pandoc -f html -t native
</script>
^D
[]
```