aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn MacFarlane <[email protected]>2025-03-10 14:41:46 -0700
committerJohn MacFarlane <[email protected]>2025-03-10 14:41:46 -0700
commit7fe8c928212197354196724e9b95b71a854fdca9 (patch)
tree4cf7da86a75a84a8dcefa5ba59c7bdb0bc828c60 /src
parentd73475cec8c7363055c482f5107a2759e1f6a277 (diff)
HTML reader: ignore style tags in the body.
They are invalid but do occur in the wild. Closes #10643.
Diffstat (limited to 'src')
-rw-r--r--src/Text/Pandoc/Readers/HTML.hs7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/Text/Pandoc/Readers/HTML.hs b/src/Text/Pandoc/Readers/HTML.hs
index c21ab67aa..fcc1147ca 100644
--- a/src/Text/Pandoc/Readers/HTML.hs
+++ b/src/Text/Pandoc/Readers/HTML.hs
@@ -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