git.iko.soy/typeable/pandoc
on master help sign in
Shared: Fixed bug in openURL with data: URIs.

Previously the base-64 encoded bytestring was returned. We now decode it so it's a proper image! This should fix parsing of data: URLs.

commit83b9a66bf468c0f32bd96be92bb571bd83b73903 authorJohn MacFarlane <jgm@berkeley.edu> dateTue 19 Nov 2013, 13:15 (13 years ago) parente290d91
1 file changed+2−1
src/Text/Pandoc/Shared.hs+2−1
src/Text/Pandoc/Shared.hs+2−1
@@ -108,6 +108,7 @@ import Text.HTML.TagSoup (renderTagsOptions, RenderOptions(..), Tag(..),
108108import qualified Data.ByteString as BS
109109import qualified Data.ByteString.Char8 as B8
110110import Text.Pandoc.Compat.Monoid
111+import Data.ByteString.Base64 (decodeLenient)
111112
112113#ifdef EMBED_DATA_FILES
113114import Text.Pandoc.Data (dataFiles)
@@ -641,7 +642,7 @@ openURL u
641642 | "data:" `isPrefixOf` u =
642643 let mime = takeWhile (/=',') $ drop 5 u
643644 contents = B8.pack $ unEscapeString $ drop 1 $ dropWhile (/=',') u
644− in return $ Right (contents, Just mime)
645+ in return $ Right (decodeLenient contents, Just mime)
645646#ifdef HTTP_CONDUIT
646647 | otherwise = E.try $ do
647648 req <- parseUrl u