git.iko.soy/typeable/pandoc
on master help sign in
fetchItem: improved mime type guessing.

Strip a fragment like `?#iefix` from the extension before doing the mime lookup.

commit85ff3c57710dc96e4f7e80b51d85f93bffca8a3b authorJohn MacFarlane <fiddlosopher@gmail.com> dateSat 2 Aug 2014, 16:32 (12 years ago) parent1d137fb
1 file changed+5−4
src/Text/Pandoc/Shared.hs+5−4
src/Text/Pandoc/Shared.hs+5−4
@@ -775,12 +775,13 @@ fetchItem sourceURL s =
775775 Nothing -> openURL s' -- will throw error
776776 (Nothing, _) -> E.try readLocalFile -- get from local file system
777777 where readLocalFile = do
778− let mime = case takeExtension s of
779− ".gz" -> getMimeType $ dropExtension s
780− x -> getMimeType x
781− cont <- BS.readFile $ unEscapeString $ dropFragmentAndQuery s
778+ cont <- BS.readFile fp
782779 return (cont, mime)
783780 dropFragmentAndQuery = takeWhile (\c -> c /= '?' && c /= '#')
781+ fp = unEscapeString $ dropFragmentAndQuery s
782+ mime = case takeExtension fp of
783+ ".gz" -> getMimeType $ dropExtension fp
784+ x -> getMimeType x
784785 ensureEscaped = escapeURIString isAllowedInURI
785786
786787-- | Like 'fetchItem', but also looks for items in a 'MediaBag'.