From 903d11b537de938434b92a38f8d9b2f8c623a49b Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Wed, 17 May 2023 17:02:59 -0700 Subject: HTML reader: fix iframe with data URI of an image. Closes #8856. In this case we don't want to try to parse the data at the URL. Instead, create an image inside a div. --- src/Text/Pandoc/Readers/HTML.hs | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/Text/Pandoc/Readers/HTML.hs b/src/Text/Pandoc/Readers/HTML.hs index eff642d2e..3ef95e020 100644 --- a/src/Text/Pandoc/Readers/HTML.hs +++ b/src/Text/Pandoc/Readers/HTML.hs @@ -476,11 +476,18 @@ pIframe = try $ do if T.null url then ignore $ renderTags' [tag, TagClose "iframe"] else catchError - (do (bs, _) <- openURL url - let inp = UTF8.toText bs - opts <- readerOpts <$> getState - Pandoc _ contents <- readHtml opts inp - return $ B.divWith ("",["iframe"],[]) $ B.fromList contents) + (do (bs, mbMime) <- openURL url + case mbMime of + Just mt + | "text/html" `T.isPrefixOf` mt -> do + let inp = UTF8.toText bs + opts <- readerOpts <$> getState + Pandoc _ contents <- readHtml opts inp + return $ B.divWith ("",["iframe"],[]) $ B.fromList contents + | "image/" `T.isPrefixOf` mt -> do + return $ B.divWith ("",["iframe"],[]) $ + B.plain $ B.image url "" mempty + _ -> return $ B.divWith ("",["iframe"],[("src", url)]) $ mempty) (\e -> do logMessage $ CouldNotFetchResource url (renderError e) ignore $ renderTags' [tag, TagClose "iframe"]) -- cgit v1.2.3