From e290d91c93b265ce7763797a5c995d29fb683c67 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Tue, 19 Nov 2013 13:09:34 -0800 Subject: MIME: In looking up extensions, drop the encoding info. E.g. for 'image/jpg;base64' we should lookup 'image/jpg'. --- src/Text/Pandoc/MIME.hs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/Text/Pandoc') diff --git a/src/Text/Pandoc/MIME.hs b/src/Text/Pandoc/MIME.hs index d9cb94a33..1f5f6f862 100644 --- a/src/Text/Pandoc/MIME.hs +++ b/src/Text/Pandoc/MIME.hs @@ -40,7 +40,8 @@ getMimeType f = M.lookup (map toLower $ drop 1 $ takeExtension f) mimeTypes where mimeTypes = M.fromList mimeTypesList extensionFromMimeType :: String -> Maybe String -extensionFromMimeType mimetype = M.lookup mimetype reverseMimeTypes +extensionFromMimeType mimetype = M.lookup (takeWhile (/=';') mimetype) reverseMimeTypes + -- note: we just look up the basic mime type, dropping the content-encoding etc. where reverseMimeTypes = M.fromList $ map (\(k,v) -> (v,k)) mimeTypesList mimeTypesList :: [(String, String)] -- cgit v1.2.3