HTML reader: ignore style tags in the body.

They are invalid but do occur in the wild.
Closes #10643.
This commit is contained in:
John MacFarlane
2025-03-10 14:41:46 -07:00
parent d73475cec8
commit 7fe8c92821
+5 -2
View File
@@ -242,7 +242,7 @@ block = ((do
"main" -> pDiv
"figure" -> pFigure
"iframe" -> pIframe
"style" -> pRawHtmlBlock
"style" -> mempty <$ pHtmlBlock "style" -- see #10643
"textarea" -> pRawHtmlBlock
"switch"
| epubExts
@@ -537,7 +537,7 @@ pIframe = try $ do
pRawHtmlBlock :: PandocMonad m => TagParser m Blocks
pRawHtmlBlock = do
raw <- pHtmlBlock "script" <|> pHtmlBlock "style" <|> pHtmlBlock "textarea"
raw <- pHtmlBlock "script" <|> pHtmlBlock "textarea"
<|> pRawTag
exts <- getOption readerExtensions
if extensionEnabled Ext_raw_html exts && not (T.null raw)
@@ -716,6 +716,7 @@ inline = pTagText <|> do
"input"
| lookup "type" attr == Just "checkbox"
-> asks inListItem >>= guard >> pCheckbox
"style" -> mempty <$ pHtmlBlock "style" -- see #10643
"script"
| Just x <- lookup "type" attr
, "math/tex" `T.isPrefixOf` x -> pScriptMath
@@ -1080,6 +1081,8 @@ isInlineTag :: Tag Text -> Bool
isInlineTag t = isCommentTag t || case t of
TagOpen "script" _ -> "math/tex" `T.isPrefixOf` fromAttrib "type" t
TagClose "script" -> True
TagOpen "style" _ -> True -- see #10643, invalid but it happens
TagClose "style" -> True
TagOpen name _ -> isInlineTagName name
TagClose name -> isInlineTagName name
_ -> False