RTF writer: properly handle images in data URIs.

See #7771.
This commit is contained in:
John MacFarlane 2021-12-22 11:59:07 -08:00
parent c4f6e6cb57
commit 811601aa8b

View file

@ -43,10 +43,11 @@ rtfEmbedImage opts x@(Image attr _ (src,_)) = catchError
(do result <- P.fetchItem src (do result <- P.fetchItem src
case result of case result of
(imgdata, Just mime) (imgdata, Just mime)
| mime == "image/jpeg" || mime == "image/png" -> do | mime' <- T.takeWhile (/=';') mime
, mime' == "image/jpeg" || mime' == "image/png" -> do
let bytes = map (T.pack . printf "%02x") $ B.unpack imgdata let bytes = map (T.pack . printf "%02x") $ B.unpack imgdata
filetype <- filetype <-
case mime of case mime' of
"image/jpeg" -> return "\\jpegblip" "image/jpeg" -> return "\\jpegblip"
"image/png" -> return "\\pngblip" "image/png" -> return "\\pngblip"
_ -> throwError $ _ -> throwError $